Skip to content

feat(appender-tracing): propagate span name to logs#3466

Open
SuperFluffy wants to merge 1 commit intoopen-telemetry:mainfrom
SuperFluffy:propagate-span-name
Open

feat(appender-tracing): propagate span name to logs#3466
SuperFluffy wants to merge 1 commit intoopen-telemetry:mainfrom
SuperFluffy:propagate-span-name

Conversation

@SuperFluffy
Copy link
Copy Markdown
Contributor

Changes

Propagates the tracing span name to OTEL logs.

Similar to the experimental span attributes, the span containing the event is valuable to identify where and what happened.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@SuperFluffy SuperFluffy requested a review from a team as a code owner April 21, 2026 15:06
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.2%. Comparing base (8e95e16) to head (a1936d2).

Files with missing lines Patch % Lines
opentelemetry-appender-tracing/src/layer.rs 90.9% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3466     +/-   ##
=======================================
- Coverage   83.2%   83.2%   -0.1%     
=======================================
  Files        128     128             
  Lines      25086   25144     +58     
=======================================
+ Hits       20896   20938     +42     
- Misses      4190    4206     +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}
}
if let Some(name) = current_span_name {
log_record.add_attribute(Key::new("span.name"), AnyValue::from(name));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"span.name" - Its tricky! There is no established convention, so any name we pick can cause issues. Need to see if we can find any alternate solution.

Also, what happens when nesting of spans is there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also, what happens when nesting of spans is there?

Related to your other comment for the test - this selects the inner-most span, so the span that immediately contains the event. I think that's the most natural span to select?

Alternatively we can follow tracing-subscriber's formatting subscriber which essentially contains a list of all spans.

"span.name"

I agree. None of this is great. Maybe just name?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Given there is no way we can ensure conflict avoidance, could we avoid making that decision ourselves, and let user make that?
use_span_name("whatever name.user wants") ?
If user does not do the above, then we ignore the span-name. If the do it, then they gives us the attribute name.

WDYT?

assert_eq!(logs.len(), 1);
let log = &logs[0];

// The span.name should be the current (leaf/innermost) span
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How do we determine what innermost is what user wants?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Innermost is the most natural. Alternatively I can see collecting a list of all spans (probably not ideal).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems reasonable. Though I can see some users wanting ability to customize it. Probably we can start with this, and based on feedback, allow advanced capabilities.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could you add this as a TODO

Copy link
Copy Markdown
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

Agree we need to provide a way to attach span name, but need to also avoid picking an attribute name ourselves. See
#3466 (comment)

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