Skip to content

fix: fix trace id in logs when using set_parent nested in a trace span #2924

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SF-Zhou
Copy link

@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)

Sorry, something went wrong.

@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
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.4%. Comparing base (9dc727e) to head (5f0b8e5).

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.3%   81.4%           
=====================================
  Files        126     126           
  Lines      24251   24296   +45     
=====================================
+ Hits       19732   19779   +47     
+ Misses      4519    4517    -2     

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

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
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
@SF-Zhou SF-Zhou force-pushed the patch branch 5 times, most recently from 1f41d19 to 55799ee Compare April 14, 2025 03:48
@scottgerring
Copy link
Contributor

@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
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 force-pushed the patch branch 2 times, most recently from 46b7a4a to 888973a Compare April 16, 2025 02:22
@SF-Zhou SF-Zhou requested a review from cijothomas April 16, 2025 03:41
@SF-Zhou
Copy link
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.

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