Skip to content

trace/auto: pass span context to auto-instrumentation start hook - #9029

Open
RonFed wants to merge 1 commit into
open-telemetry:mainfrom
RonFed:autosdk_ctx_fix
Open

RonFed wants to merge 1 commit into
open-telemetry:mainfrom
RonFed:autosdk_ctx_fix

Conversation

@RonFed

@RonFed RonFed commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

The auto-instrumentation start hook can use the context hierarchy to track relationships between spans, the way the SDK does with SpanFromContext.
autoTracer.Start calls the hook before ContextWithSpan, so the hook receives the parent's context rather than the new span's. When sibling spans started from the same context overlap in time, they then look like one span is the parent of the other.

ctx, parent := tracer.Start(ctx, "parent")
_, a := tracer.Start(ctx, "a")
_, b := tracer.Start(ctx, "b") // expected child of "parent", reported as child of "a"
b.End()
a.End()
parent.End()

@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.1%. Comparing base (9e72307) to head (40ce169).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #9029   +/-   ##
=====================================
  Coverage   89.1%   89.1%           
=====================================
  Files        338     338           
  Lines      22274   22274           
=====================================
+ Hits       19854   19856    +2     
+ Misses      2420    2418    -2     
Files with missing lines Coverage Δ
trace/auto.go 98.0% <100.0%> (ø)

... and 2 files with indirect coverage changes

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

@ps-mir ps-mir left a comment

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.

Change looks ok, suggestion for additional test and changelog entry.

Comment thread CHANGELOG.md Outdated
Comment thread trace/auto_test.go
@RonFed
RonFed force-pushed the autosdk_ctx_fix branch 2 times, most recently from 56a43f7 to 87f77f8 Compare September 29, 2026 07:14
@RonFed

RonFed commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

thanks @ps-mir, addressed your comments

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.

3 participants