Skip to content

Conversation

@SF-Zhou
Copy link
Contributor

@SF-Zhou SF-Zhou commented Apr 10, 2025

Fixes #2824.

Changes

When using distributed tracing and calling set_parent to set the context, the currently obtained trace_id was incorrect. This PR fixes this issue.

This fix has been validated in online production environments. For users with the same requirements, they can temporarily opt to use the patched opentelemetry-appender-tracing-patched crate.

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)

@SF-Zhou SF-Zhou requested a review from a team as a code owner April 10, 2025 06:19
@SF-Zhou SF-Zhou changed the title appender-tracing: include attributes in logs when nested in tracing c… appender-tracing: include attributes in logs when nested in tracing context Apr 10, 2025
@SF-Zhou SF-Zhou changed the title appender-tracing: include attributes in logs when nested in tracing context appender-tracing: include attributes in logs when nested in tracing crate's span Apr 10, 2025
@codecov
Copy link

codecov bot commented Apr 10, 2025

Codecov Report

Attention: Patch coverage is 98.27586% with 1 line in your changes missing coverage. Please review.

Project coverage is 81.2%. Comparing base (bf22aeb) to head (ad031b8).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
opentelemetry-appender-tracing/src/layer.rs 98.2% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #2924   +/-   ##
=====================================
  Coverage   81.1%   81.2%           
=====================================
  Files        126     126           
  Lines      24794   24839   +45     
=====================================
+ Hits       20131   20173   +42     
- Misses      4663    4666    +3     

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

@SF-Zhou SF-Zhou changed the title appender-tracing: include attributes in logs when nested in tracing crate's span fix: include attributes in logs when nested in tracing crate's span Apr 10, 2025
@scottgerring
Copy link
Member

Hey @SF-Zhou thanks for opening the PR!
Can you give a few more details on what exactly led to this?

@SF-Zhou
Copy link
Contributor Author

SF-Zhou commented Apr 10, 2025

Hey @SF-Zhou thanks for opening the PR! Can you give a few more details on what exactly led to this?

Sure. The description of the PR has been updated.

@SF-Zhou SF-Zhou changed the title fix: include attributes in logs when nested in tracing crate's span fix: use the correct tracing id and attributes in logs when nested within a tracing span Apr 10, 2025
@scottgerring
Copy link
Member

@bantonsson I think your eyes on this would be helpful!

@scottgerring scottgerring requested a review from bantonsson April 14, 2025 11:26
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!

Requesting changing to address the comment below:
See https://github.com/open-telemetry/opentelemetry-rust/pull/2924/files#r2044837776

@SF-Zhou SF-Zhou changed the title fix: use the correct tracing id and attributes in logs when nested within a tracing span fix: fix trace id in logs when nested in tracing span with set_parent Apr 16, 2025
@SF-Zhou
Copy link
Contributor Author

SF-Zhou commented Apr 16, 2025

Thanks!

Requesting changing to address the comment below: See https://github.com/open-telemetry/opentelemetry-rust/pull/2924/files#r2044837776

Done.

@SF-Zhou SF-Zhou changed the title fix: fix trace id in logs when nested in tracing span with set_parent fix: fix trace ID in logs when using set_parent nested in a trace span Apr 16, 2025
@SF-Zhou SF-Zhou changed the title fix: fix trace ID in logs when using set_parent nested in a trace span fix: fix trace id in logs when using set_parent nested in a trace span Apr 16, 2025
@SF-Zhou SF-Zhou requested a review from cijothomas April 16, 2025 03:41
@SF-Zhou
Copy link
Contributor Author

SF-Zhou commented Apr 21, 2025

@cijothomas could you please review the updates when convenient? If everything looks good, we can proceed to merge.

@cijothomas cijothomas dismissed their stale review May 23, 2025 14:53

Concerning change was reverted, thanks!

@cijothomas cijothomas merged commit 200885a into open-telemetry:main May 23, 2025
27 checks passed
@SF-Zhou SF-Zhou deleted the patch branch May 24, 2025 01:14
bantonsson pushed a commit to bantonsson/opentelemetry-rust that referenced this pull request Oct 9, 2025
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.

[Bug]: traceId not correctly set for logs when using set_parent with opentelemetry-appender-tracing

5 participants