Skip to content

Conversation

@leghadjeu-christian
Copy link
Contributor

@leghadjeu-christian leghadjeu-christian commented Dec 5, 2025

Fixes #3221
Design discussion issue (if applicable) #

Changes

Add experimental experimental_span_attributes feature to enrich log records with attributes from active tracing spans.
When enabled, span attributes are automatically included in log records. Event attributes take precedence on conflicts.

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)

@leghadjeu-christian leghadjeu-christian requested a review from a team as a code owner December 5, 2025 21:24
@leghadjeu-christian leghadjeu-christian marked this pull request as draft December 5, 2025 21:26
@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 88.40580% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.5%. Comparing base (2b63b75) to head (1225ca1).

Files with missing lines Patch % Lines
opentelemetry-appender-tracing/src/layer.rs 88.4% 24 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main   #3282    +/-   ##
======================================
  Coverage   80.5%   80.5%            
======================================
  Files        129     129            
  Lines      23294   23496   +202     
======================================
+ Hits       18756   18935   +179     
- Misses      4538    4561    +23     

☔ 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.

@leghadjeu-christian leghadjeu-christian marked this pull request as ready for review December 10, 2025 01:11
@leghadjeu-christian leghadjeu-christian changed the title [WIP]: feat(appender-tracing): add experimental span attributes enrichment feat(appender-tracing): add experimental span attributes enrichment Dec 10, 2025

#[test]
#[cfg(feature = "experimental_span_attributes")]
fn test_span_context_enrichment_enabled() {
Copy link
Member

Choose a reason for hiding this comment

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

can you add a test for nested spans? I am curious on how that works as well...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a new test test_nested_spans_use_innermost_attributes
that verifies nested span behavior. It confirms that events correctly associate with the innermost active span and only include its attributes, ensuring proper scoping.

Copy link
Member

Choose a reason for hiding this comment

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

why we restrict to innermost active span? That'd mean we lose everything from non-innermost span, partially defeating the purpose. We should get attributes from all spans.

We can look at how fmt subscriber handles this, and mimic its behavior closely.

Copy link
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.

Thanks for working on this. I left comments. We need to do this with high performance, avoiding allocations wherever feasible.
Also, we need to have tests for nested spans.
please check comments.

@cijothomas
Copy link
Member

Pinging to discussion #3282 (comment) about using attributes from innermost span only vs everything.

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.

Add tracing span support to tracing events in opentelemetry-appender-tracing

2 participants