Skip to content

Create parentless roots for v4 trace summaries - #128

Merged
kxzk merged 4 commits into
simplepractice:mainfrom
bcdonadio:fix/explicit-trace-id-roots
Oct 8, 2026
Merged

kxzk merged 4 commits into
simplepractice:mainfrom
bcdonadio:fix/explicit-trace-id-roots

Conversation

@bcdonadio

@bcdonadio bcdonadio commented Oct 6, 2026 •

Copy link
Copy Markdown

TL;DR

Create parentless roots for explicit trace_id: values so v4 trace summaries can select input/output.

Why

Depends on #129 for legacy summaries. Explicit roots use root sampling. This differs from Python's placeholder-parent behavior. Applications that replace the ID generator retain the placeholder parent.

Checklist

  • Has label
  • Has linked issue
  • Tests added for new behavior
  • Docs updated (if user-facing)

Related to #125. Stack order: #129, then #128.

Verification

Automated tests, RuboCop, and live Cloud CLI/UI checks passed for parentage and input/output. The internal v4 summary query remains unverified.


Note

Medium Risk
Changes core span parentage, sampling, and context for explicit trace IDs; behavior shifts for apps relying on placeholder parents, though custom ID generators retain the old path.

Overview
Explicit trace_id: on start_observation / observe now starts a parentless OpenTelemetry root (even with an active span), uses the provider root sampler, and restores ambient context when the block ends. Children inside the explicit root still attach to that root; repeated calls with the same ID remain separate roots and still get the legacy as_root mark for v4 trace input/output summaries.

Implementation adds RootSpanIdGenerator on the Langfuse tracer provider and routes explicit roots through with_trace_id, which clears the ambient parent and Langfuse trace baggage claim while scoping the requested trace ID to the span start. otel_tracer_and_id_generator keeps tracer and generator paired if the provider is reconfigured. Replacing Langfuse.tracer_provider.id_generator falls back to the previous placeholder-parent behavior (documented).

Reviewed by Cursor Bugbot for commit 2c05bb8. Bugbot is set up for automated code reviews on this repo. Configure here.

@bcdonadio
bcdonadio marked this pull request as ready for review October 6, 2026 17:14
@kxzk kxzk changed the title Create true roots for explicit trace IDs Create parentless roots for v4 trace summaries Oct 7, 2026
@kxzk kxzk added the bug Something isn't working label Oct 7, 2026
@kxzk
kxzk changed the base branch from main to fix/explicit-trace-root-attribute October 7, 2026 13:25
@kxzk
kxzk force-pushed the fix/explicit-trace-id-roots branch from 15b0605 to df60724 Compare October 7, 2026 13:29
@kxzk
kxzk force-pushed the fix/explicit-trace-id-roots branch 3 times, most recently from e65893f to ac97f76 Compare October 8, 2026 12:09
bcdonadio and others added 4 commits October 8, 2026 06:57
Avoid unexported synthetic parents so v4 can aggregate observation
input and output from real roots. Preserve nesting, sampling and no-op
correlation; pair the tracer and generator across provider lifecycle
changes. Sixteen regressions and the full locked Ruby 3.4.5 suite pass.

Signed-off-by: Bernardo Donadio <bcdonadio@bcdonadio.com>
Keep the explicit trace ID behavior documented in docs/TRACING.md.
The top-level README addition is unnecessary for this fix.

Signed-off-by: Bernardo Donadio <bcdonadio@bcdonadio.com>
@kxzk
kxzk force-pushed the fix/explicit-trace-id-roots branch from c1d61e9 to 2c05bb8 Compare October 8, 2026 13:57
@kxzk
kxzk changed the base branch from fix/explicit-trace-root-attribute to main October 8, 2026 13:57
@kxzk kxzk closed this Oct 8, 2026
@kxzk kxzk reopened this Oct 8, 2026
@kxzk
kxzk merged commit 801f0ed into simplepractice:main Oct 8, 2026
15 checks passed
@kxzk kxzk mentioned this pull request Oct 12, 2026
3 of 4 tasks
benlangfeld added a commit to powerhome/nitro-intelligence.rb that referenced this pull request Oct 19, 2026
langfuse-rb 0.12.4 creates a parentless root for an explicit trace_id
(simplepractice/langfuse-rb#128) and marks it for legacy trace summaries
(#129). That is the behaviour #137 carried as its own start_root_span and
ID generator, so upgrade from 0.7.0 and use upstream's RootSpanIdGenerator
and create_otel_span root path instead.

langfuse-rb's SpanProcessor now owns the batching, so the tracer provider
passes it the exporter rather than adding a separate batch processor. The
seeded-root regression specs from #137 pass unchanged against upstream's
implementation, and a new spec covers the as_root marker.

Closes #164

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants