Skip to content

fix(otel): make HTTP trace export survive app-server runtimes#14300

Merged
owenlin0 merged 1 commit intomainfrom
owen/otel-trace-export-fix
Mar 11, 2026
Merged

fix(otel): make HTTP trace export survive app-server runtimes#14300
owenlin0 merged 1 commit intomainfrom
owen/otel-trace-export-fix

Conversation

@owenlin0
Copy link
Copy Markdown
Collaborator

@owenlin0 owenlin0 commented Mar 11, 2026

Summary

This PR fixes OTLP HTTP trace export in runtimes where the previous exporter setup was unreliable, especially around app-server usage. It also removes the old codex_otel::otel_provider compatibility shim and switches remaining call sites over to the crate-root codex_otel::OtelProvider export.

What changed

  • Use a runtime-safe OTLP HTTP trace exporter path for Tokio runtimes.
  • Add an async HTTP client path for trace export when we are already inside a multi-thread Tokio runtime.
  • Make provider shutdown flush traces before tearing down the tracer provider.
  • Add loopback coverage that verifies traces are actually sent to /v1/traces:
    • outside Tokio
    • inside a multi-thread Tokio runtime
    • inside a current-thread Tokio runtime
  • Remove the codex_otel::otel_provider shim and update remaining imports.

Why

I hit cases where spans were being created correctly but never made it to the collector. The issue turned out to be in exporter/runtime behavior rather than the span plumbing itself. This PR narrows that gap and gives us regression coverage for the actual export path.

@owenlin0
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

} => {
debug!("Using OTLP Http exporter for traces: {endpoint}");

if crate::otlp::current_tokio_runtime_is_multi_thread() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

when is it not true?

Copy link
Copy Markdown
Collaborator Author

@owenlin0 owenlin0 Mar 11, 2026

Choose a reason for hiding this comment

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

our main binaries are multi-threaded, but app-server-test-client and unit tests marked with just #[tokio::test] are single-threaded

@owenlin0 owenlin0 merged commit 509f001 into main Mar 11, 2026
31 checks passed
@owenlin0 owenlin0 deleted the owen/otel-trace-export-fix branch March 11, 2026 16:59
@github-actions github-actions bot locked and limited conversation to collaborators Mar 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants