Skip to content

No field support for field names that are not Rust identifiers in #[instrument] #1437

Open
@jerusdp

Description

@jerusdp

Bug Report

Version

tracing v0.1.26
│ │ │ │ ├── tracing-attributes v0.1.15 (proc-macro)
│ │ │ │ └── tracing-core v0.1.18

Platform

Linux odin 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Description

I cannot construct a field on the instrumented trace with a name that is not a Rust ident.

Documentation indicates that all features available in span! are available in #[instrument].

(I have not tested this feature in span!).

Code:

#[instrument(name = "API Gateway event handler", skip(e, _c), fields("comment" = "Event data is not recorded as it contains personal data."))]

Expected this to happen:
A field, comment, would be created containing the note and appear in my logs.

Instead this happened:
error: expected ident
--> src/handler.rs:43:70
|
43 | #[instrument(name = "API Gateway event handler", skip(e, _c), fields("comment" = "Event data is not recorded as it contains personal data...

The editor highlights "comment" as the offending term.

Metadata

Metadata

Assignees

No one assigned

    Labels

    crate/attributesRelated to the `tracing-attributes` cratekind/featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions