Skip to content

Inbound traceparent is only honored on the first request after startup #459

Open

Description

@ahmedabdou14

With OTLP trace export on, the inbound traceparent is used as the parent for the first request after the server starts. Later requests start a new trace, so the upstream traceparent no longer matches the caller's trace id. http.server.request spans also never show up in the exporter.

Seen on the 0.9.0 wheel. I read main (7f81813) and telemetry/http.rs is unchanged since v0.9.0, but I did not run main.

Repro

export OTEL_TRACES_EXPORTER=otlp OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \
  OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318 OTEL_SERVICE_NAME=agentic-api
agentic-server --gateway-port 9000   # llm_api_base points at a vLLM behind a proxy that logs request headers

for i in 1 2 3; do
  TID=$(openssl rand -hex 16)
  curl -s localhost:9000/v1/responses -H 'content-type: application/json' \
    -H "traceparent: 00-$TID-00f067aa0ba902b7-01" \
    -d '{"model":"m","input":"hi","store":false,"max_output_tokens":16}' >/dev/null
  echo "req$i in=$TID"
done

Compare $TID with the trace id in the traceparent the upstream received for each request.

Expected: the upstream traceparent carries the caller's trace id on every request.

Actual (inbound id, then the id vLLM received):

req1 in=952a61e1fb13231006f3913a5d89f358 up=952a61e1fb13231006f3913a5d89f358
req2 in=47cb6063c5e58c8990ea1f2252f1f1a8 up=12c8c8bd966c46200ff0b8c48b9a97c5
req3 in=933fc27ade19dbb938441399e4689a38 up=90643ed13b4a39f56fb5c06497c353aa

In the collector, agentic.rehydrate, agentic.inference_round, http.client.request, agentic.tool.execute and agentic.persist arrive, but no http.server.request. Their parent span id points at a span that was never exported, and agentic.execute was missing in some runs.

I have not found the cause. track_request calls span.set_parent(...) after creating the span (crates/agentic-server/src/telemetry/http.rs), which is where I would look first.

Related: #279, #338, #339 added the tracing and are closed. I could not find an open issue for this.

Activity

  1. ENCHIGO commented on Oct 20, 2026

    @ENCHIGO
    Contributor

    I tried to reproduce this and couldn't, on either current main (62471db) or v0.9.0.

    I used your exact steps: the real agentic-server binary, OTEL_TRACES_EXPORTER=otlp with http/protobuf pointed at a local OTLP receiver, a header-logging upstream as --llm-api-base, and three curl requests, each with a fresh traceparent. Result on v0.9.0:

    in=28293424c73588866d7d2a13c6d68201  up=00-28293424c73588866d7d2a13c6d68201-5754e17756969239-01
    in=ffde2e4b723f398c0172a7d3898bb10d  up=00-ffde2e4b723f398c0172a7d3898bb10d-5ee5a6791ae3172a-01
    in=1d57bd550e9905f477ee8b7a0909259f  up=00-1d57bd550e9905f477ee8b7a0909259f-6e37fe334a9622b2-01
    

    Every upstream request continued its own caller's trace, and the export batch contained the POST /v1/responses server spans. main gave the same result.

    Since the code path looks correct, something in your setup is probably different. Could you share:

    • How you installed it: the wheel's launcher, or the binary directly? Anything in ~/.agentic-api/config.toml?
    • RUST_LOG and any OTEL_TRACES_SAMPLER* settings.
    • Whether a proxy sits between curl and the gateway, or between the gateway and vLLM. If the gateway-to-vLLM proxy rewrites traceparent, that would match this symptom.

    #473 adds a regression test for this exact behaviour (three requests, three trace ids, three exported server spans) and fixes the related #460, but I've left this issue open until we can reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions