Skip to main content
Breaking change: OpenTelemetry functionality has been moved to the separate @braintrust/otel npm package. This solves ESM build issues in Next.js (edge), Cloudflare Workers, Bun, and TanStack applications, and adds support for both OpenTelemetry v1 and v2.
If you’re not using OpenTelemetry, just upgrade the SDK. If you are using OpenTelemetry features, follow the full migration steps:
1

Upgrade the SDK

2

Install the OpenTelemetry package

Add @braintrust/otel to your project:
3

Update imports

Replace imports from braintrust with imports from @braintrust/otel for OpenTelemetry-related functionality.
  • BraintrustSpanProcessor Before:
    After:
  • BraintrustExporter Before:
    After:
  • Distributed tracing utilities Before:
    After:
4

Update OTel compatibility

If you were previously using the BRAINTRUST_OTEL_COMPAT=true environment variable to enable bidirectional interoperability between Braintrust and OpenTelemetry spans, you should now use setupOtelCompat() instead.Before:
After:
Important: Call setupOtelCompat() before creating any Braintrust loggers or OpenTelemetry spans.
If you’re writing tests and need to reset the compatibility mode between test cases, use resetOtelCompat():
5

Verify your setup

After updating imports and, if necessary, OTel compatibility, verify your integration works correctly:
  1. Run your build process to ensure no import errors.
  2. Test that traces appear in Braintrust as expected.
  3. If using distributed tracing, verify parent-child relationships are maintained.
If you encounter issues during migration, please open an issue with details about your setup and the problem you’re experiencing.