Skip to content

info_span!/error_span!/warn_span! macros accept constants for field names, but #[instrument(fields(...))] seemingly doesnt #2969

@merc1031

Description

@merc1031

Bug Report

Version

cargo tree | grep tracing
│   │   └── tracing v0.1.40
│   │       ├── tracing-attributes v0.1.27 (proc-macro)
│   │       └── tracing-core v0.1.32
│   │   │   │   └── tracing v0.1.40 (*)
│   │   │   └── tracing v0.1.40 (*)
│   │   │   └── tracing v0.1.40 (*)
│   │   └── tracing v0.1.40 (*)
│   └── tracing v0.1.40 (*)
├── axum-tracing-opentelemetry v0.18.0
│   ├── tracing v0.1.40 (*)
│   ├── tracing-opentelemetry v0.23.0
│   │   ├── tracing v0.1.40 (*)
│   │   ├── tracing-core v0.1.32 (*)
│   │   ├── tracing-log v0.2.0
│   │   │   └── tracing-core v0.1.32 (*)
│   │   └── tracing-subscriber v0.3.18
│   │       ├── tracing v0.1.40 (*)
│   │       ├── tracing-core v0.1.32 (*)
│   │       ├── tracing-log v0.2.0 (*)
│   │       ├── tracing-serde v0.1.3
│   │       │   ├── tracing-core v0.1.32 (*)
│   └── tracing-opentelemetry-instrumentation-sdk v0.18.0
│       ├── tracing v0.1.40 (*)
│       └── tracing-opentelemetry v0.23.0 (*)
│   │   │   └── tracing v0.1.40 (*)
│   │   │   ├── tracing v0.1.40 (*)
│   │   ├── tracing v0.1.40 (*)
│   ├── tracing v0.1.40 (*)
│       ├── tracing v0.1.40 (*)
│   │   │   ├── tracing v0.1.40 (*)
│   │   │   └── tracing v0.1.40 (*)
│   ├── tracing v0.1.40 (*)
│   ├── tracing-core v0.1.32 (*)
│   ├── tracing-ecs v0.4.0
│   │   ├── tracing v0.1.40 (*)
│   │   ├── tracing-core v0.1.32 (*)
│   │   ├── tracing-log v0.2.0 (*)
│   │   └── tracing-subscriber v0.3.18 (*)
│   ├── tracing-elastic-apm v3.2.3 (https://github.com/merc1031/tracing-elastic-apm.git?rev=bd8cc1f9de82915c888bfd33460dc2a9e766d902#bd8cc1f9)
│   │   ├── tracing v0.1.40 (*)
│   │   ├── tracing-subscriber v0.3.18 (*)
│   ├── tracing-subscriber v0.3.18 (*)
├── tracing v0.1.40 (*)
├── tracing-core v0.1.32 (*)
├── tracing-ecs v0.4.0 (*)
├── tracing-elastic-apm v3.2.3 (https://github.com/merc1031/tracing-elastic-apm.git?rev=bd8cc1f9de82915c888bfd33460dc2a9e766d902#bd8cc1f9) (*)
├── tracing-subscriber v0.3.18 (*)

Platform

uname -a                  
Linux lloucas-ThinkPad-T15-Gen-2i 6.2.0-39-generic #40-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 14 14:18:00 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Description

I expected to be able to use a constant in the fields portion of the instrument macro.

I wrote the following expecting it to work like info_span!({OUTCOME} = "success"); (which does work)

pub const OUTCOME: &str = "outcome";

#[instrument(fields({OUTCOME} = "success"))]
fn name() {

However it doesnt compile. Am I misunderstanding?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions