Skip to content

fix(core): send OTLP/protobuf to Arize AX so trace and span ids survive - #178

Open
zaccromero wants to merge 1 commit into
Arize-ai:mainfrom
zaccromero:fix/arize-otlp-protobuf-ids
Open

zaccromero wants to merge 1 commit into
Arize-ai:mainfrom
zaccromero:fix/arize-otlp-protobuf-ids

Conversation

@zaccromero

Copy link
Copy Markdown

Summary

The Arize AX exporter posts OTLP/JSON with hex-encoded traceId / spanId, as the OTLP/JSON spec requires. Arize's OTLP/HTTP JSON intake decodes those two fields as base64 instead (the generic protobuf-JSON mapping for bytes), so every id is stored corrupted: a 32-hex trace id arrives as 48 hex characters and a 16-hex span id as 24.

Trees from a single harness still look correct, because every id in a payload is corrupted the same way. The damage shows up when anything else needs the ids:

  • the trace id in Arize never matches the id the harness generated or logged;
  • a harness span can never join a trace started by another OpenTelemetry producer, even when parent ids are correct on the wire.

Reproduction: export a span with traceId=0123456789abcdef0123456789abcdef. Before this change the trace is not found under that id; it is found under base64decode("0123456789abcdef0123456789abcdef").hex(), a 48-hex value. After this change it is stored under exactly 0123456789abcdef0123456789abcdef, with its parent span id intact.

This PR sends the Arize payload through the existing otlp_json_to_protobuf encoder (already used for Phoenix) with Content-Type: application/x-protobuf. The encoder hex-decodes ids into raw bytes, so Arize stores exactly what was generated. It stays stdlib-only. The skill guides that described the transport as HTTP/JSON are corrected; their point (no Python dependencies needed) still holds.

Phoenix is unaffected: it was already sent as protobuf.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other

How tested

  • tests/core/test_common.py::TestSendSpan::test_arize_direct_send now asserts application/x-protobuf, that the body equals the encoder's output for the injected payload, and that the raw trace and span id bytes are on the wire. The existing assertions on arize.project.name / arize.project.type placement are kept, run against the encoded payload.
  • Against a live Arize AX space, with Claude Code 2.1.311 and Codex CLI 0.163.0: a Claude Code turn exported under a known trace id was retrieved with ax spans export --trace-id <that exact 32-hex id>, with its root span parented to the expected span id. Before the change the same lookup returned nothing and the spans were present only under the base64-misdecoded id.
  • uv run pytest tests/ -m "not slow" on this branch: 2767 passed, 4 skipped, 8 deselected, 1 xfailed.
  • uv run pre-commit run --all-files: all hooks pass (isort, black, ruff, mypy for core and every harness).

Checklist

  • Tests pass (uv run pytest tests/ -m "not slow")
  • Pre-commit clean (uv run pre-commit run --all-files)
  • Ran the code-review skill and addressed findings
  • Docs updated if needed

Related: #170 touches the transcript parser and is independent of this change.

🤖 Generated with Claude Code

The Arize AX exporter posted OTLP/JSON with hex-encoded traceId/spanId, as
the OTLP/JSON spec requires. Arize's OTLP/HTTP JSON intake decodes those
fields as base64 (the generic protobuf-JSON bytes mapping) instead, so every
id was stored corrupted: a 32-hex trace id arrives as 48 hex chars and a
16-hex span id as 24.

Trees from one harness still looked right, because every id in a payload was
corrupted the same way. But a span could never join a trace started by any
other OpenTelemetry producer, and ids in Arize never match the ids the
harness generated.

Send the payload through the existing otlp_json_to_protobuf encoder (already
used for Phoenix) with Content-Type application/x-protobuf. The encoder
hex-decodes ids into raw bytes, so Arize stores exactly what was generated.
Still stdlib-only.

Also correct the skill guides that described the transport as HTTP/JSON.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

This branch has not been deployed

No deployments
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.

1 participant