Skip to content

refactor(runtime): use OpenTelemetry trace propagation - #13688

Open
PeaBrane wants to merge 2 commits into
mainfrom
rupei/refactor-runtime-trace-context
Open

refactor(runtime): use OpenTelemetry trace propagation#13688
PeaBrane wants to merge 2 commits into
mainfrom
rupei/refactor-runtime-trace-context

Conversation

@PeaBrane

@PeaBrane PeaBrane commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace duplicated manual W3C trace-context parsing across HTTP, NATS, and TCP with OpenTelemetry propagation
  • centralize carrier extraction behind a thin GenericHeaderExtractor while retaining exact W3C trace/span ID field-width checks
  • preserve raw tracestate, request-ID behavior, trace flags, and existing public helper signatures
  • remove 106 net lines without adding a dependency

Validation

  • focused existing runtime tests for valid/malformed traceparent parsing, unsampled propagation, header injection, inbound request spans, distributed context, and sampled/unsampled root decisions (8 passed)
  • cargo fmt --all -- --check
  • git diff --check main..HEAD
  • release B/C frontend benchmark against mock workers with W3C trace headers, 8,192 measured requests per trial, zero errors:
    • concurrency 256, three paired trials: frontend CPU/request -0.19%, throughput +0.05%
    • concurrency 1024, five paired trials: frontend CPU/request +0.89%, throughput -1.41%, mean latency +1.89%, p95 -0.58%, p99 -3.80%

The stressed-point movement is minor and mixed rather than a material regression. Every trial used a fresh frontend/mocker topology, separate warmup, identical JSONL tracing, and disjoint CPU placement.

Summary by CodeRabbit

  • New Features

    • Improved distributed tracing across HTTP, NATS, and other supported request headers.
    • Trace context and request identifiers are now preserved more consistently.
    • Added support for tracing headers from newer trace versions.
  • Bug Fixes

    • Improved validation and normalization of tracing metadata.
    • Standardized trace extraction behavior across supported transports.

Signed-off-by: PeaBrane <yanrpei@gmail.com>
@PeaBrane
PeaBrane marked this pull request as ready for review August 23, 2026 04:31
@PeaBrane
PeaBrane requested review from a team as code owners August 23, 2026 04:31
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 78b5fc3d-5261-4117-99d6-01533452086d

📥 Commits

Reviewing files that changed from the base of the PR and between dbecec8 and fe98f90.

📒 Files selected for processing (1)
  • lib/runtime/src/logging.rs

Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review.


Walkthrough

Traceparent parsing now uses a shared OpenTelemetry propagator for multiple header formats. The shared extractor returns trace metadata, tracestate, request identifiers, and optional OTel context. Request and payload span constructors use this extraction path.

Changes

Trace context extraction

Layer / File(s) Summary
Shared propagator extraction
lib/runtime/src/logging.rs
parse_traceparent and TraceParent::from_headers use generic headers and shared OpenTelemetry extraction. The extractor validates field widths and preserves trace metadata, tracestate, and request identifiers.
Span constructor integration
lib/runtime/src/logging.rs
Inference, system, NATS, TCP, and HashMap span constructors consume the shared extraction result and OTel context.
Parser behavior validation
lib/runtime/src/logging.rs
Tests cover normalized flags, future traceparent versions, and clearing unsupported flag bits.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to fe98f

This PR centralizes trace propagation without changing the documented behavior, and its focused validation shows no material performance regression; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the changes and validation, but it omits the required Related Issues section from the repository template. Add the required Related Issues section and either link the relevant issue or confirm that this PR has no related issue.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change to use OpenTelemetry trace propagation in the runtime.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Comment thread lib/runtime/src/logging.rs Outdated
Signed-off-by: PeaBrane <yanrpei@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant