Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use the tracing event name as the otel event name #188

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

zzlk
Copy link
Contributor

@zzlk zzlk commented Jan 28, 2025

Motivation

When using the tracing macros and trying to explicitly set the 'name' of the event, for example:

event!(name: "test", Level::INFO, field1 = "field1");

This event will get emitted to open telemetry as an event with an empty name. The 'name' information will be completely lost. It seems common for this information to get dropped actually, see: tokio-rs/tracing#2774

Solution

In on_event I set the event name to event.metadata().name() which should be the name of the event that is handed down from tracing. I am unfamiliar with this code and the wider tracing/opentelemtry ecosystem so I am not sure this is a good way to solve this issue, or if this is even a real issue. I am also not sure what this change would break, and what kind of backward compatibility guarantees there might be. I have tested my use case (sending traces/events to jaeger) and can confirm that the names of events are being recorded correctly with this change.

Copy link
Collaborator

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might make sense.

@djc djc merged commit 1e4ad6b into tokio-rs:v0.1.x Jan 29, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants