Skip to main content
Temporal is a durable execution platform for building reliable distributed applications. Braintrust integrates with Temporal to automatically trace workflows and activities, providing full observability across your workflow executions. The integration captures:
  • Workflow execution spans
  • Activity execution spans with metadata
  • Distributed traces across workers
  • Parent-child relationships between workflows and activities

Setup

Install the required packages:
Temporal integration requires TypeScript SDK v2.1.0+.

Trace with Temporal

Braintrust provides automatic tracing for Temporal workflows and activities. The integration uses a plugin pattern for TypeScript and Python, and OpenTelemetry interceptors for Go.

TypeScript

Use the BraintrustTemporalPlugin with both your Temporal Client and Worker. The plugin automatically instruments your workflows and activities, creating spans that capture execution details and propagate trace context across process boundaries.
The plugin automatically:
  • Creates parent spans for workflow executions
  • Creates child spans for activity executions
  • Propagates trace context across workers via headers
  • Handles concurrent workflow execution safely

Python

To trace Temporal workflows and activities automatically, call braintrust.auto_instrument() (Python SDK v0.19.0 or later). It adds BraintrustPlugin to any Temporal client or worker you create, so you don’t need to configure anything manually.
To instrument manually, import BraintrustPlugin from braintrust.integrations.temporal, instantiate it, and pass it to both your Temporal client and worker via plugins=[plugin]. The plugin intercepts workflow and activity executions to create spans with full context, including workflow IDs, activity types, and execution metadata.
The plugin handles:
  • Workflow execution spans via BraintrustWorkflowInboundInterceptor
  • Activity execution spans with workflow metadata
  • Span context serialization/deserialization via Temporal headers
  • Temporal sandbox compatibility for braintrust imports
The braintrust.contrib.temporal module is deprecated in Python SDK v0.19.0. Imports from braintrust.contrib.temporal still work but emit a DeprecationWarning. Update imports to braintrust.integrations.temporal.

Go

Go uses OpenTelemetry interceptors to integrate Braintrust with Temporal. This approach leverages Temporal’s native OpenTelemetry support, routing spans through the Braintrust SDK’s trace provider for unified observability.

Resources