Skip to content

Level macros (info!, debug!, etc.) reject dotted field names when using name: specifier #3407

@martintmk

Description

@martintmk

Bug Report

Version

└── tracing v0.1.41
    ├── pin-project-lite v0.2.16
    ├── tracing-attributes v0.1.30 (proc-macro)
    │   ├── proc-macro2 v1.0.103
    │   │   └── unicode-ident v1.0.22
    │   ├── quote v1.0.42
    │   │   └── proc-macro2 v1.0.103 (*)
    │   └── syn v2.0.110
    │       ├── proc-macro2 v1.0.103 (*)
    │       ├── quote v1.0.42 (*)
    │       └── unicode-ident v1.0.22
    └── tracing-core v0.1.34
        └── once_cell v1.21.3

Platform

64-bit (Windows)

Description

The info!, debug!, warn!, and error! macros fail to accept field names containing dots (e.g., order.id) when the name: event specifier is used. The event! macro handles this case correctly.

The "dot" in a property name is a very common for attributes/properties that follow Open Telemetry semantic conventions.

// WORKS
event!(name: "order.received.ok", Level::INFO, order.id = 123, "order received");

// DOES NOT WORK ("." in the property name)
info!(name: "order.received.ok", order.id = 123, "order received");
debug!(name: "order.received.ok", order.id = 123, "order received");
error!(name: "order.received.ok", order.id = 123, "order received");
warn!(name: "order.received.ok", order.id = 123, "order received");

// WORKS (no "." in the property name)
info!(name: "order.received.ok", order_id = 123, "order received");
debug!(name: "order.received.ok", order_id = 123, "order received");
error!(name: "order.received.ok", order_id = 123, "order received");
warn!(name: "order.received.ok", order_id = 123, "order received");

// WORKS (omitting the "name:" even specifier)
info!(order.id = 123, "order received");
debug!(order.id = 123, "order received");
error!(order.id = 123, "order received");
warn!(order.id = 123, "order received");

As a workaround we have to use the event! macro which does not have this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    crate/tracingRelated to the `tracing` cratekind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions