feat(evals): bump braintrust to 3.x; first-party BraintrustSpanProcessor OTEL sink - #2355
Conversation
|
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Confidence score: 5/5
- Safe to merge after the addressed issues were fixed.
Architecture diagram
sequenceDiagram
participant App as otel.ts (initializeTracerProvider)
participant Provider as NodeTracerProvider
participant Processor as BraintrustSpanProcessor
participant BraintrustAPI as Braintrust API
Note over App,BraintrustAPI: NEW: First‑party span processor replaces generic OTLP exporter
App->>App: Read BRAINTRUST_API_KEY
alt API key present
App->>App: Derive project name (stagehand/stagehand-dev) from CI flag
App->>App: Read BRAINTRUST_OTEL_PARENT (default: project_name:…)
App->>App: Read BRAINTRUST_OTEL_URL
opt BRAINTRUST_OTEL_URL set
App->>App: Strip suffix /otel/v1/traces to get apiUrl
end
App->>Processor: new BraintrustSpanProcessor({apiKey, parent, filterAISpans: false, apiUrl?})
Note over Processor: filterAISpans: false ensures manual spans (task/agent/verifier) reach Braintrust
Processor->>BraintrustAPI: Authenticate with apiKey
App->>Provider: addSpanProcessor(Processor)
end
Note over App: Also still configures LangSmith exporter if enabled
Note over Provider,BraintrustAPI: During evaluation run
Provider->>Processor: onStart(span)
Processor->>Processor: Check filterAISpans (false → always pass)
Processor->>Processor: Enrich span with parent context
loop Every batch or scheduled flush
Processor->>BraintrustAPI: Export spans (via Braintrust OTLP endpoint)
BraintrustAPI-->>Processor: Acknowledge
end
Provider->>Processor: shutdown()
Processor->>BraintrustAPI: Final flush
BraintrustAPI-->>Processor: Complete
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
dd2ef3e to
bf90266
Compare
bf90266 to
4d9a7f7
Compare
4d9a7f7 to
e1169ec
Compare
|
Superseded by the Stagehand 4.0 retarget stack (#2757–#2762). Main moved to the 4.0 monorepo restructure (packages/core → packages/sdk-ts; evals package restructured), so this 3.x-era diff no longer applies. The OTEL/LangSmith tracing work — plus native-span capture via 4.0's global tracer and claude_code/codex agent spans — is reimplemented additively on 4.0 in the new stack. |
why
@braintrust/otelrequiresbraintrust>=1.0(every published version), so the pinned 0.4.x blocked the first-party OTEL processor. 3.x unlocks it — richerai.*span handling than a generic OTLP exporter.what changed
braintrust^0.4.10→^3.21.0(all used exports verified intact:Eval,flush,traced,wrapAISDK,loginToState);@braintrust/oteladdedframework/otel.ts: Braintrust sink →BraintrustSpanProcessor({ apiKey, parent, filterAISpans: false })(falseso manual task/agent/verifier spans reach Braintrust too);BRAINTRUST_OTEL_URL→apiUrllib/AISdkClientWrapped.ts: typing-only fix (ReturnType<wrapAISDK>collapses in 3.x) — no runtime change@opentelemetry/exporter-trace-otlp-protodep removedtest plan
evals experimentsagainst live Braintrust (report-layer parity); dual-backend otel run (env: browserbase)Stack 5/5 · base: #2354
Summary by cubic
Upgrade
braintrustto 3.x and switch our OTEL sink to the first‑partyBraintrustSpanProcessor. This improvesai.*span capture, removes the generic OTLP exporter, and updates tests to cover parent override andBRAINTRUST_OTEL_URL→apiUrlderivation.New Features
BraintrustSpanProcessor({ apiKey, parent, filterAISpans: false })for Braintrust traces.BRAINTRUST_OTEL_URLis set, deriveapiUrlby stripping/otel/v1/traces. Tests mockBraintrustSpanProcessorand assert this derivation.Dependencies
braintrustfrom^0.4.10to^3.21.0.@braintrust/otel^0.2.1.@opentelemetry/exporter-trace-otlp-proto.AISdkClientWrappedforwrapAISDKreturn shape (no runtime change).Written for commit e1169ec. Summary will update on new commits.