Skip to content

refactor(otel)!: Decouple from OpenTelemetry SDK versions - #2765

Open
Luca Forstner (lforst) wants to merge 2 commits into
v4from
lforst/otel-sdk-independence
Open

Luca Forstner (lforst) wants to merge 2 commits into
v4from
lforst/otel-sdk-independence

Conversation

@lforst

@lforst Luca Forstner (lforst) commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Closes braintrustdata/braintrust-sdk-javascript#2745

  • Remove OpenTelemetry SDK and exporter peer dependencies from @braintrust/otel, so applications can select compatible OpenTelemetry 1, 2, or 3 packages.

  • Breaking: BraintrustSpanProcessor and BraintrustExporter now wrap instances supplied by the application.
    Previously, they created their own exporter and batch processor, which could batch spans twice and force a flush after each export.

      import {
        BraintrustExporter,
        BraintrustSpanProcessor,
        braintrustOtlpConfig,
      } from "@braintrust/otel";
      import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
      import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
      
      const exporter = new BraintrustExporter({
        // New helper supplies the Braintrust endpoint and headers.
        exporter: new OTLPTraceExporter(
          braintrustOtlpConfig({ parent: "project_name:my-project" }),
        ),
      });
      const processor = new BraintrustSpanProcessor({
        processor: new BatchSpanProcessor(exporter), // OpenTelemetry 1/2
      });
  • Require an explicit project or experiment through parent or BRAINTRUST_PARENT, instead of silently using a default project.

  • Use public OpenTelemetry context APIs instead of private storage internals, and preserve sampling flags and trace state when mixing Braintrust and OpenTelemetry spans.

  • Flush all registered OpenTelemetry processors before scorer queries.
    Previously, each registration replaced the previous callback; registrations now also get removed on shutdown.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T12:43:22.201543Z 9ae5c02 PR opened
ℹ️ About Codex in GitHub

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

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

2 participants