What’s changed from v0.x to v1.x in the TypeScript SDK?
If you’re not using OpenTelemetry features, upgrading is straightforward—just update the package version (npm install braintrust@next). No import changes are required.
If you are using OpenTelemetry integration, follow the migration steps below to update your imports.
Breaking changes
- OpenTelemetry support moved to
@braintrust/otel: OpenTelemetry functionality has been separated into a dedicated package. This solves ESM build issues that blocked usage in Next.js (edge), Cloudflare Workers, Bun, and TanStack applications. The new package supports both OpenTelemetry v1 and v2.
Upgrade to v1.0.0
Update your imports if you’re using any of these OpenTelemetry features:BraintrustSpanProcessorBraintrustExporter- Distributed tracing utilities (
contextFromSpanExport,addSpanParentToBaggage,parentFromHeaders) - OpenTelemetry compatibility mode
1. Upgrade the SDK
2. Install the OpenTelemetry package
Add@braintrust/otel to your project:
3. Update imports
Replace imports frombraintrust with imports from @braintrust/otel for OpenTelemetry-related functionality.
BraintrustSpanProcessor
-
Before:
-
After:
-
Before:
-
After:
-
Before:
-
After:
4. Update OTel compatibility
If you were previously using theBRAINTRUST_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.
resetOtelCompat():
5. Verify your setup
After updating imports and, if necessary, OTel compatibility, verify your integration works correctly:- Run your build process to ensure no import errors.
- Test that traces appear in Braintrust as expected.
- If using distributed tracing, verify parent-child relationships are maintained.