Applies to:
- Plan -
- Deployment - Hosted and BYOC
- Use case - How to route OTLP spans to experiments/rows using braintrust.parent vs x-bt-parent when using a shared collector (BYOC and hosted)
Summary
OTLP spans sent to/otel/v1/traces through a shared collector are routed using either a per-span braintrust.parent attribute or the x-bt-parent request header.
What is happening
When you send OTLP traces to/otel/v1/traces through a shared collector, Braintrust uses each span’s braintrust.parent attribute to determine where the span is routed. For spans without that attribute, Braintrust uses the x-bt-parent header supplied with that request.
Fix or suggestion
Option 1: Per-span routing (recommended)
- Set
braintrust.parenton every span you emit, including child spans. - Use the intended experiment row span’s exported parent value as the attribute value.
Option 2: Per-request header (alternative)
Thex-bt-parent header is a request-wide default. Use this option only for requests containing spans for a single experiment row. For requests containing spans for multiple experiment rows, set braintrust.parent on every span, including child spans.
- For spans without
braintrust.parent, set the request’sx-bt-parentheader to the intended experiment row span’s exported parent value.
Verify routing
- Send a test trace using the intended row span’s exported parent value and verify that it appears beneath that row.
The API key used by the collector must have write access to every destination you route spans to.