Skip to content

event!(name: ...) is ignored in "full" and "json" output #2774

@safinaskar

Description

@safinaskar

Bug Report

Version

├── tracing v0.1.40
│   ├── tracing-attributes v0.1.27 (proc-macro)
│   └── tracing-core v0.1.32
└── tracing-subscriber v0.3.17
    ├── tracing-core v0.1.32 (*)
    ├── tracing-log v0.1.3
    │   └── tracing-core v0.1.32 (*)
    └── tracing-serde v0.1.3
        └── tracing-core v0.1.32 (*)

Platform

Linux comp 5.10.0-0.deb9.24-amd64 #1 SMP Debian 5.10.179-5~deb9u1 (2023-09-01) x86_64 GNU/Linux

Crates

tracing, tracing-subscriber

Description

Name in event!(name: ..., ...) is ignored in both "json" and "full" output in tracing-subscriber.

tracing-subscriber description for "json" output reads: "This is intended for production use" ( https://docs.rs/tracing-subscriber/0.3.17/tracing_subscriber/fmt/format/index.html ). So, I'm assuming that output should be complete or at least can be configured to be complete. Same for "full". Word "full" assumes that output will be full or at least can be configured to be full. Yet in both outputs name is absent. Here is my code:

fn main() {
    use tracing_subscriber::layer::SubscriberExt;
    use tracing_subscriber::util::SubscriberInitExt;
    use tracing::Level;
    use tracing::event;
    tracing_subscriber::Registry::default()
        .with(tracing_subscriber::fmt::layer()
            // .json()
        )
        .init();
    event!(name: "n", Level::INFO, "a");
}

Here is output ("full" mode):

2023-10-24T18:18:06.222325Z  INFO trac: a

Here is output if I uncomment .json():

{"timestamp":"2023-10-24T18:18:45.843139Z","level":"INFO","fields":{"message":"a"},"target":"trac"}

So, in both cases name is absent. Moreover, when I search (using Ctrl-F) word "name" in https://docs.rs/tracing-subscriber/0.3.17/tracing_subscriber/fmt/struct.Layer.html , I find nothing. Same for https://docs.rs/tracing-subscriber/0.3.17/tracing_subscriber/fmt/format/struct.Json.html and https://docs.rs/tracing-subscriber/0.3.17/tracing_subscriber/fmt/format/struct.Full.html . So, nothing suggests I can somehow configure this.

This is inconsistent, because span names are printed by default. But event's - no. Why you added names at all? They should behave similar to span's names

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions