> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bronto.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Temporal traces and metrics to Bronto via OpenTelemetry

> Trace Temporal Workflows, Activities and the AI agents that run in them, and send Temporal SDK metrics to Bronto with OpenTelemetry.

[Temporal](https://temporal.io) runs Workflows durably: if a process crashes, the Workflow continues where it left off, and failed Activities are retried. That makes it a common runtime for long-running AI agents. With OpenTelemetry, you can see each Workflow in Bronto as one trace: the client that started it, the Workflow, every Activity attempt and, for agents, every model request and tool call.

This page covers the Temporal Python, TypeScript and Go SDKs:

* **Traces** from each SDK's OpenTelemetry plugin or, in Go, its tracing interceptor
* **Metrics** from each SDK's metrics exporter or, in Go, its metrics handler
* **AI agents** run on Temporal, built with the Claude Agent SDK (Python, TypeScript) or the Anthropic Go SDK (Go)

> [!NOTE]
>
> This page was verified on **November 26, 2026** with `temporalio` 1.37.0, `temporalio-claude-agent-sdk` 0.0.3, `claude-agent-sdk` 0.2.168 (Claude Code 2.1.301), the OpenTelemetry Python SDK 1.45.2 and a local Temporal dev server (Temporal CLI 1.10.1). The TypeScript examples were verified on **November 27, 2026** with `@temporalio/*` 1.27.0, `@temporalio/interceptors-opentelemetry-v2` 1.27.0, `@anthropic-ai/claude-agent-sdk` 0.3.332 (Claude Code 2.1.332), the OpenTelemetry JS SDK 2.12.1 and Node.js 24. The Go examples were verified on **November 27, 2026** with `go.temporal.io/sdk` 1.52.0, `go.temporal.io/sdk/contrib/opentelemetry` 0.9.0, `github.com/anthropics/anthropic-sdk-go` 1.84.0, the OpenTelemetry Go SDK 1.47.0 and Go 1.27. GenAI libraries and semantic conventions are evolving rapidly, so package configuration and emitted attributes can change between releases. Keep your instrumentation current and verify the fields emitted by the version you deploy.

## Prerequisites

* Python 3.11+, Node.js 20+ or Go 1.26+, and the Temporal SDK for your language
* A Temporal Service: Temporal Cloud, a self-hosted cluster or `temporal server start-dev` for local development
* An OTel Collector configured using [Connect OpenTelemetry to Bronto](https://docs.bronto.io/agent-setup/open-telemetry.md), or a direct OTLP exporter (below)

## Send traces and metrics to Bronto

**Via a Collector**: point the application's OTLP exporter at the Collector, then configure the Collector using [Connect OpenTelemetry to Bronto](https://docs.bronto.io/agent-setup/open-telemetry.md). This is recommended in production.

**Direct export**: point the exporter at the Bronto ingestion endpoint and add your API key:

```bash theme={"dark"}
export OTEL_EXPORTER_OTLP_ENDPOINT="https://ingestion.eu.bronto.io"
export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_HEADERS="x-bronto-api-key=<YOUR_API_KEY>"
export OTEL_SERVICE_NAME="order-worker"
```

| Region | Endpoint |
| - | - |
| EU | `https://ingestion.eu.bronto.io` |
| US | `https://ingestion.us.bronto.io` |

The OpenTelemetry SDK appends `/v1/traces`. Give the Worker and the process that starts Workflows different service names, so you can tell them apart in a trace. See [API Keys](https://docs.bronto.io/Account-Management/API-Keys.md) for how to create a key with ingestion permissions.

In TypeScript, the OTLP trace exporter reads these variables. In Go, the OTLP trace and metric exporters both read them. The TypeScript and Go examples set the service name in code, in the tracer provider's resource.

## Trace Workflows and Activities

> [tab] Python
>
> ```bash theme={"dark"}
> pip install temporalio opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
> ```
>
> Register a tracer provider, then add the SDK's `OpenTelemetryPlugin` to the client. Do this in every process that uses Temporal, both the Worker and the code that starts Workflows, so their spans join one trace:
>
> ```python theme={"dark"}
> from opentelemetry import trace
> from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
> from opentelemetry.sdk.trace.export import BatchSpanProcessor
> from temporalio.client import Client
> from temporalio.contrib.opentelemetry import OpenTelemetryPlugin, create_tracer_provider
> from temporalio.worker import Worker
>
> provider = create_tracer_provider()
> provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
> trace.set_tracer_provider(provider)
>
> client = await Client.connect("localhost:7233", plugins=[OpenTelemetryPlugin(add_temporal_spans=True)])
>
> worker = Worker(client, task_queue="orders", workflows=[OrderWorkflow], activities=[fetch_order, charge_card])
> await worker.run()
> ```
>
> Use `create_tracer_provider()` instead of the OpenTelemetry SDK's `TracerProvider`. Workflow code can be replayed, and the provider it returns is replay-safe. Register it before `Client.connect`. A Worker created from the client uses the client's plugins, so you don't pass `plugins` to `Worker` again. Short-lived processes, such as a script that starts one Workflow, should call `provider.force_flush()` before they exit.
>
> > [!NOTE]
> >
> > `OpenTelemetryPlugin` is marked experimental in `temporalio` 1.37.0. Older guides use `TracingInterceptor` from the same module. It still works, but its Workflow span has a duration of zero, so it doesn't show how long the Workflow ran.

> [tab] TypeScript
>
> ```bash theme={"dark"}
> npm install @temporalio/client @temporalio/worker @temporalio/workflow @temporalio/activity \
>   @temporalio/interceptors-opentelemetry-v2 @opentelemetry/api @opentelemetry/resources \
>   @opentelemetry/sdk-trace-base @opentelemetry/sdk-trace-node @opentelemetry/exporter-trace-otlp-proto \
>   @opentelemetry/semantic-conventions
> ```
>
> Create a tracer provider and a span processor, and pass them to the SDK's `OpenTelemetryPlugin`. Do this in every process that uses Temporal, both the Worker and the code that starts Workflows, so their spans join one trace:
>
> ```typescript theme={"dark"}
> // instrumentation.ts
> import { resourceFromAttributes } from '@opentelemetry/resources';
> import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
> import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
> import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
> import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
>
> export function setupTracing(serviceName: string) {
>   const resource = resourceFromAttributes({ [ATTR_SERVICE_NAME]: serviceName });
>   // The exporter reads OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS.
>   const spanProcessor = new BatchSpanProcessor(new OTLPTraceExporter());
>   const provider = new NodeTracerProvider({ resource, spanProcessors: [spanProcessor] });
>   provider.register();
>   return { resource, spanProcessor, provider };
> }
> ```
>
> ```typescript theme={"dark"}
> // worker.ts
> import { NativeConnection, Worker } from '@temporalio/worker';
> import { OpenTelemetryPlugin } from '@temporalio/interceptors-opentelemetry-v2';
> import * as activities from './activities';
> import { setupTracing } from './instrumentation';
>
> async function main() {
>   const { resource, spanProcessor, provider } = setupTracing('order-worker');
>   const connection = await NativeConnection.connect({ address: 'localhost:7233' });
>   const worker = await Worker.create({
>     connection,
>     taskQueue: 'orders',
>     workflowsPath: require.resolve('./workflows'),
>     activities,
>     plugins: [new OpenTelemetryPlugin({ resource, spanProcessor })],
>   });
>   await worker.run();
>   await provider.forceFlush();
>   await provider.shutdown();
> }
> main().catch((e) => { console.error(e); process.exit(1); });
> ```
>
> ```typescript theme={"dark"}
> // starter.ts
> import { Client, Connection } from '@temporalio/client';
> import { OpenTelemetryPlugin } from '@temporalio/interceptors-opentelemetry-v2';
> import { setupTracing } from './instrumentation';
>
> async function main() {
>   const { resource, spanProcessor, provider } = setupTracing('order-client');
>   const connection = await Connection.connect({ address: 'localhost:7233' });
>   const client = new Client({ connection, plugins: [new OpenTelemetryPlugin({ resource, spanProcessor })] });
>   const handle = await client.workflow.start('orderWorkflow', {
>     args: ['42'], taskQueue: 'orders', workflowId: `order-${Date.now()}`,
>   });
>   console.log(await handle.result());
>   await provider.forceFlush();
>   await provider.shutdown();
> }
> main().catch((e) => { console.error(e); process.exit(1); });
> ```
>
> The plugin adds a client interceptor, an Activity interceptor and a sink that exports the spans of Workflow code. The Workflow sink uses the `resource` and `spanProcessor` you pass, so pass the same ones that the provider uses. Short-lived processes, such as a script that starts one Workflow, should call `provider.forceFlush()` and `provider.shutdown()` before they exit.
>
> Use `@temporalio/interceptors-opentelemetry-v2` with the OpenTelemetry JS SDK 2.x. For SDK 1.x, use the older `@temporalio/interceptors-opentelemetry` package.
>
> > [!NOTE]
> >
> > `OpenTelemetryPlugin` is marked experimental in the TypeScript SDK too.

> [tab] Go
>
> ```bash theme={"dark"}
> go get go.temporal.io/sdk go.temporal.io/sdk/contrib/opentelemetry \
>   go.opentelemetry.io/otel go.opentelemetry.io/otel/sdk \
>   go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp
> ```
>
> The Go SDK has no OpenTelemetry plugin. Register a tracer provider, then add the SDK's tracing interceptor from `NewTracingInterceptor` to the client. Do this in every process that uses Temporal, both the Worker and the code that starts Workflows, so their spans join one trace:
>
> ```go theme={"dark"}
> import (
>     "context"
>     "log"
>
>     "go.opentelemetry.io/otel"
>     "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
>     "go.opentelemetry.io/otel/sdk/resource"
>     sdktrace "go.opentelemetry.io/otel/sdk/trace"
>     semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
>     "go.temporal.io/sdk/client"
>     temporalotel "go.temporal.io/sdk/contrib/opentelemetry"
>     "go.temporal.io/sdk/interceptor"
>     "go.temporal.io/sdk/worker"
> )
>
> ctx := context.Background()
> res, _ := resource.Merge(resource.Default(), resource.NewSchemaless(semconv.ServiceName("order-worker")))
>
> texp, err := otlptracehttp.New(ctx) // reads the OTEL_EXPORTER_OTLP_* variables
> if err != nil {
>     log.Fatal(err)
> }
> tp := sdktrace.NewTracerProvider(sdktrace.WithBatcher(texp), sdktrace.WithResource(res))
> otel.SetTracerProvider(tp)
> defer tp.Shutdown(ctx)
>
> tracing, err := temporalotel.NewTracingInterceptor(temporalotel.TracerOptions{})
> if err != nil {
>     log.Fatal(err)
> }
>
> c, err := client.Dial(client.Options{
>     HostPort:     "localhost:7233",
>     Interceptors: []interceptor.ClientInterceptor{tracing},
> })
> if err != nil {
>     log.Fatal(err)
> }
> defer c.Close()
>
> w := worker.New(c, "orders", worker.Options{})
> w.RegisterWorkflow(OrderWorkflow)
> w.RegisterActivity(FetchOrder)
> w.RegisterActivity(ChargeCard)
> err = w.Run(nil)
> ```
>
> A Worker created from the client uses the client's interceptors, so you don't pass them to `worker.Options` again. Short-lived processes, such as a program that starts one Workflow, should call `tp.ForceFlush(ctx)` and `tp.Shutdown(ctx)` before they exit.
>
> Unlike Python's older `TracingInterceptor`, the Go interceptor's `RunWorkflow` span has a real duration.

### Spans

One Workflow that runs two Activities, where `charge_card` fails once and succeeds on retry, produces this trace:

> [tab] Python
>
> ![Bronto trace waterfall of OrderWorkflow in Python: StartWorkflow, RunWorkflow, StartActivity and RunActivity spans for fetch\_order and charge\_card, with the first charge\_card attempt in error and a second attempt after the retry interval](https://mintcdn.com/bronto/_Nx3BR7Rshe2zZlA/images/integrations/assets/images/temporal-waterfall-python.png?fit=max\&auto=format\&n=_Nx3BR7Rshe2zZlA\&q=85\&s=e301ce935df0e0951b0ec37affb611e6)
>
> The Workflow trace in Bronto: 7 spans over 1.45 s, with the failed charge\_card attempt and its retry

> [tab] TypeScript
>
> ![Bronto trace waterfall of orderWorkflow in TypeScript: StartWorkflow, RunWorkflow, StartActivity and RunActivity spans for fetchOrder and chargeCard, with the first chargeCard attempt in error and a second attempt after the retry interval](https://mintcdn.com/bronto/_Nx3BR7Rshe2zZlA/images/integrations/assets/images/temporal-waterfall-typescript.png?fit=max\&auto=format\&n=_Nx3BR7Rshe2zZlA\&q=85\&s=4ad8bcf68683bda6b6b862545e7b33f6)
>
> The Workflow trace in Bronto: 7 spans over 1.66 s, with the failed chargeCard attempt and its retry

> [tab] Go
>
> ![Bronto trace waterfall of OrderWorkflow in Go: an ask root span, then StartWorkflow, RunWorkflow, StartActivity and RunActivity spans for FetchOrder and ChargeCard, with the first ChargeCard attempt in error and a second attempt after the retry interval](https://mintcdn.com/bronto/_Nx3BR7Rshe2zZlA/images/integrations/assets/images/temporal-waterfall-go.png?fit=max\&auto=format\&n=_Nx3BR7Rshe2zZlA\&q=85\&s=71fcd580e55dbf6fef013524c3b065e2)
>
> The Workflow trace in Bronto: 8 spans over 1.08 s, with the failed ChargeCard attempt and its retry
>
> The `ask` span at the root comes from the example's own code that starts the Workflow, not from the interceptor.

In each trace, `RunWorkflow` is a child of `StartWorkflow`, `StartActivity` is a child of `RunWorkflow`, and each `RunActivity` attempt is a child of its `StartActivity`.

Open [Tracing](https://docs.bronto.io/tracing/explore-traces.md) and select the `StartWorkflow:<Workflow type>` operation to find Workflows, then open a trace to see the Workflow as a waterfall. Each Activity attempt is its own `RunActivity` span, so retries and the wait between them are visible. A failed attempt has an error status and an exception event with the error message.

The TypeScript and Go SDKs produce the same trace. Span names use the function names of your Workflows and Activities, for example `StartWorkflow:orderWorkflow` and `RunActivity:chargeCard` in TypeScript, or `RunActivity:ChargeCard` in Go. In Go, the `exception.type` of a failed attempt is the Go error type, for example `*errors.errorString`.

![Span details of a failed RunActivity span in Bronto, showing the error status, the exception message and type, and the temporalActivityID, temporalRunID and temporalWorkflowID attributes](https://mintcdn.com/bronto/_Nx3BR7Rshe2zZlA/images/integrations/assets/images/temporal-failed-activity-span.png?fit=max\&auto=format\&n=_Nx3BR7Rshe2zZlA\&q=85\&s=352f6d72b5cf55e6e7248dd71afedb5d)

A failed Activity attempt with its exception event and Temporal attributes

| Python and Go | TypeScript | Spans | Notes |
| - | - | - | - |
| `temporalWorkflowID` | `temporalWorkflowId` on `RunActivity`, `workflowId` on `RunWorkflow` | `RunWorkflow`, `RunActivity` | The Workflow ID. Search for it to find all spans of one Workflow |
| `temporalRunID` | `run_id` on `RunActivity`, `runId` on `RunWorkflow` | `RunWorkflow`, `RunActivity` | The Run ID of the Workflow Execution |
| `temporalActivityID` | `temporalActivityId` | `RunActivity` | The Activity ID |

In TypeScript, the `RunWorkflow` span also carries `workflowType`.

The `RunWorkflow` span lasts from the start of the Workflow to its completion. The root `StartWorkflow` span ends when the Temporal Service accepts the start request, so its duration is the latency of that call, not of the Workflow.

## Trace AI agents on Temporal

An agent on Temporal runs its model requests and tool calls from Workflow and Activity code, so they can join the Workflow's trace. How you run the agent depends on the language.

> [tab] Python
>
> Temporal's [Claude Agent SDK integration](https://docs.temporal.io/develop/python/integrations/claude-agent-sdk) runs a Claude agent inside a Workflow. The agent runs in a Claude Code subprocess that the Worker starts from an Activity. Tools can call Activities, so a crash doesn't lose the run. The integration doesn't emit spans of its own, but `OpenTelemetryPlugin` passes the trace context to the Claude Code subprocess. With Claude Code's telemetry turned on, its model requests and tool calls join the Workflow's trace.
>
> ```bash theme={"dark"}
> pip install temporalio temporalio-claude-agent-sdk claude-agent-sdk opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
> ```
>
> ```python theme={"dark"}
> import asyncio
> from datetime import timedelta
> from typing import Any
>
> from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient, ResultMessage, create_sdk_mcp_server, tool
> from temporalio import activity, workflow
> from temporalio.claude_agent_sdk import ClaudeAgentSDKPlugin, TemporalTransport
> from temporalio.client import Client
> from temporalio.contrib.opentelemetry import OpenTelemetryPlugin
> from temporalio.exceptions import ApplicationError
> from temporalio.worker import Worker
>
> @activity.defn
> async def fetch_weather(city: str) -> str:
>     return f"It is 21 C and sunny in {city}."
>
> @tool("get_weather", "Get the current weather in a city", {"city": str})
> async def get_weather(args: dict[str, Any]) -> dict[str, Any]:
>     text = await workflow.execute_activity(fetch_weather, args["city"], start_to_close_timeout=timedelta(seconds=30))
>     return {"content": [{"type": "text", "text": text}]}
>
> @workflow.defn
> class WeatherAgent:
>     @workflow.run
>     async def run(self, prompt: str) -> str:
>         options = ClaudeAgentOptions(
>             model="claude-haiku-5-5",
>             tools=[],
>             setting_sources=[],
>             mcp_servers={"demo": create_sdk_mcp_server("demo", tools=[get_weather])},
>             allowed_tools=["mcp__demo__get_weather"],
>         )
>         async with ClaudeSDKClient(options=options, transport=TemporalTransport(options)) as client:
>             await client.query(prompt)
>             async for msg in client.receive_response():
>                 if isinstance(msg, ResultMessage):
>                     # Failed runs also arrive as a ResultMessage. Raise, so they count as failed Workflows.
>                     if msg.is_error or msg.subtype != "success":
>                         raise ApplicationError(f"The agent run failed: {msg.subtype}")
>                     return msg.result or ""
>         raise RuntimeError("The agent returned no result")
>
> async def main():
>     # Register the tracer provider as in the previous section, then:
>     client = await Client.connect(
>         "localhost:7233",
>         plugins=[OpenTelemetryPlugin(add_temporal_spans=True), ClaudeAgentSDKPlugin()],
>     )
>     worker = Worker(client, task_queue="agents", workflows=[WeatherAgent], activities=[fetch_weather])
>     await worker.run()
>
> if __name__ == "__main__":
>     asyncio.run(main())
> ```
>
> Start the event loop under `if __name__ == "__main__":` in any module that defines a Workflow. Temporal imports the module again in its Workflow sandbox to validate it.
>
> Turn on Claude Code's trace export in the Worker's environment. The Claude Code subprocess inherits it, together with the `OTEL_EXPORTER_OTLP_*` variables from [Send traces and metrics to Bronto](#send-traces-and-metrics-to-bronto) and `ANTHROPIC_API_KEY`:
>
> ```bash theme={"dark"}
> export CLAUDE_CODE_ENABLE_TELEMETRY=1
> export CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1
> export OTEL_TRACES_EXPORTER=otlp
> ```
>
> > [!WARNING]
> >
> > Don't pass these variables, or any API key, through `ClaudeAgentOptions.env`. The options are part of the Workflow's input, so they're stored in its Event History.
>
> One agent run produces this trace (trimmed):
>
> ![Bronto trace waterfall of the Python weather agent: StartWorkflow, RunWorkflow and a StartActivity with RunActivity that starts the Claude Code subprocess, with a claude\_code.interaction span that contains three claude\_code.llm\_request spans and a claude\_code.tool span with blocked\_on\_user and execution children](https://mintcdn.com/bronto/_Nx3BR7Rshe2zZlA/images/integrations/assets/images/temporal-agent-waterfall-python.png?fit=max\&auto=format\&n=_Nx3BR7Rshe2zZlA\&q=85\&s=cf3f2150cfc886dd7941e808713e8bd8)
>
> The agent trace in Bronto: 58 spans over 7.83 s. The top rows show the Workflow, the Claude Code subprocess and its model requests and tool call
>
> The screenshot shows the first rows only. Below them the trace continues with sibling `StartActivity` and `RunActivity` spans for the tool, and the `claude-agent-sdk-read`, `claude-agent-sdk-write` and `claude-agent-sdk-close` Activities. The `ask-agent` span at the root comes from the example's own code that starts the Workflow.
>
> The Workflow also runs `claude-agent-sdk-read` and `claude-agent-sdk-write` Activities to exchange messages with the subprocess. They show up as sibling spans under `RunWorkflow`.

> [tab] TypeScript
>
> Temporal doesn't have a Claude Agent SDK integration for TypeScript. Run the agent from an Activity with `@anthropic-ai/claude-agent-sdk`, and pass the Activity's trace context to the Claude Code subprocess in `TRACEPARENT`. Temporal retries the Activity if it fails, but the agent loop isn't durable step by step: a retry starts the agent again.
>
> ```bash theme={"dark"}
> npm install @anthropic-ai/claude-agent-sdk @anthropic-ai/sdk zod
> ```
>
> ```typescript theme={"dark"}
> // activities.ts
> import { Context } from '@temporalio/activity';
> import { context, propagation } from '@opentelemetry/api';
> import { createSdkMcpServer, query, tool } from '@anthropic-ai/claude-agent-sdk';
> import { z } from 'zod';
>
> const getWeather = tool('get_weather', 'Get the current weather in a city', { city: z.string() }, async ({ city }) => ({
>   content: [{ type: 'text' as const, text: `It is 21 C and sunny in ${city}.` }],
> }));
>
> export async function runAgent(prompt: string): Promise<string> {
>   // Hand the Activity's trace context to the Claude Code subprocess. Claude Code reads TRACEPARENT.
>   const carrier: Record<string, string> = {};
>   propagation.inject(context.active(), carrier);
>   const env: Record<string, string | undefined> = { ...process.env };
>   if (carrier.traceparent) env.TRACEPARENT = carrier.traceparent;
>
>   const q = query({
>     prompt,
>     options: {
>       model: 'claude-haiku-5-5',
>       tools: [],
>       settingSources: [],
>       mcpServers: { demo: createSdkMcpServer({ name: 'demo', tools: [getWeather] }) },
>       allowedTools: ['mcp__demo__get_weather'],
>       maxTurns: 4,
>       env,
>     },
>   });
>   for await (const msg of q) {
>     Context.current().heartbeat();
>     if (msg.type !== 'result') continue;
>     // API errors can arrive with subtype 'success' and is_error set. Throw, so the Activity retries and counts as failed.
>     if (msg.subtype === 'success' && !msg.is_error) return msg.result;
>     throw new Error(`The agent run failed: ${msg.subtype}`);
>   }
>   throw new Error('The agent returned no result');
> }
> ```
>
> ```typescript theme={"dark"}
> // workflows.ts
> import { proxyActivities } from '@temporalio/workflow';
> import type * as activities from './activities';
>
> const { runAgent } = proxyActivities<typeof activities>({
>   startToCloseTimeout: '5 minutes',
>   retry: { maximumAttempts: 2 },
> });
>
> export async function weatherAgent(prompt: string): Promise<string> {
>   return await runAgent(prompt);
> }
> ```
>
> Register the Worker with `OpenTelemetryPlugin` as in the previous section. `@anthropic-ai/claude-agent-sdk` is ESM-only: compiling a CommonJS project that imports it with `tsc` fails. The examples were run with `tsx`.
>
> Claude Code inherits the environment you pass in `env`. Turn on its trace export in the Worker's environment, together with the `OTEL_EXPORTER_OTLP_*` variables from [Send traces and metrics to Bronto](#send-traces-and-metrics-to-bronto) and `ANTHROPIC_API_KEY`. Set `OTEL_SERVICE_NAME` there for the Claude Code spans, for example `claude-code`. The Worker's own spans use the service name from its tracer provider.
>
> ```bash theme={"dark"}
> export CLAUDE_CODE_ENABLE_TELEMETRY=1
> export CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1
> export OTEL_TRACES_EXPORTER=otlp
> ```
>
> The Activity runs in the Worker, so `options.env` isn't stored in the Workflow's history. Keep secrets in the Worker's environment anyway, and don't pass them as Activity arguments.
>
> One agent run produces this trace:
>
> ![Bronto trace waterfall of the TypeScript weather agent: StartWorkflow, RunWorkflow, StartActivity and RunActivity:runAgent, with a claude\_code.interaction span that contains three claude\_code.llm\_request spans and a claude\_code.tool span with blocked\_on\_user and execution children](https://mintcdn.com/bronto/_Nx3BR7Rshe2zZlA/images/integrations/assets/images/temporal-agent-waterfall-typescript.png?fit=max\&auto=format\&n=_Nx3BR7Rshe2zZlA\&q=85\&s=c09ca29a59f882174ff1e0126dc6a0ed)
>
> The agent trace in Bronto: 11 spans over 11 s, from the Workflow to Claude Code's model requests and tool call
>
> The tool runs in the Activity's process, so there is no Workflow span for it.

> [tab] Go
>
> There is no Claude Agent SDK for Go. Call the Claude API with the [Anthropic Go SDK](https://github.com/anthropics/anthropic-sdk-go) from an Activity. The SDK has built-in OpenTelemetry support: it creates an `anthropic.messages.create` span for each API call, as a child of the Activity span. It uses the tracer provider you registered with `otel.SetTracerProvider`, so you don't need a separate instrumentation package.
>
> ```bash theme={"dark"}
> go get github.com/anthropics/anthropic-sdk-go
> ```
>
> ```go theme={"dark"}
> func AskClaude(ctx context.Context, prompt string) (string, error) {
>     c := anthropic.NewClient() // ANTHROPIC_API_KEY from the environment
>     msg, err := c.Messages.New(ctx, anthropic.MessageNewParams{
>         Model:     "claude-haiku-5-5",
>         MaxTokens: 64,
>         Messages:  []anthropic.MessageParam{anthropic.NewUserMessage(anthropic.NewTextBlock(prompt))},
>     })
>     if err != nil {
>         return "", err
>     }
>     return msg.Content[0].Text, nil
> }
>
> func AgentWorkflow(ctx workflow.Context, prompt string) (string, error) {
>     ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{StartToCloseTimeout: time.Minute})
>     var out string
>     err := workflow.ExecuteActivity(ctx, AskClaude, prompt).Get(ctx, &out)
>     return out, err
> }
> ```
>
> Pass the Activity's `ctx` to the API call, so the span joins the trace. Keep the API key in the Worker's environment, not in Workflow input.
>
> One run produces this trace:
>
> ![Bronto trace waterfall of the Go agent: an ask root span, StartWorkflow, RunWorkflow, StartActivity and RunActivity:AskClaude, with the anthropic.messages.create span as a downstream call under the Activity](https://mintcdn.com/bronto/_Nx3BR7Rshe2zZlA/images/integrations/assets/images/temporal-agent-waterfall-go.png?fit=max\&auto=format\&n=_Nx3BR7Rshe2zZlA\&q=85\&s=0b1c25dd73b7fc643a353e89b0309748)
>
> The agent trace in Bronto: 6 spans over 730 ms, ending in the Anthropic API call
>
> The `ask` span at the root comes from the example's own code that starts the Workflow. The last span, `anthropic.messages.create`, is the API call.
>
> | Field | Spans | Notes |
> | - | - | - |
> | `gen_ai.request.model`, `gen_ai.response.model` | `anthropic.messages.create` | The requested and the served model |
> | `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens` | `anthropic.messages.create` | Tokens of the request |
> | `gen_ai.usage.cache_read.input_tokens`, `gen_ai.usage.cache_write.input_tokens` | `anthropic.messages.create` | Prompt cache tokens |
> | `gen_ai.operation.name`, `gen_ai.provider.name` | `anthropic.messages.create` | `chat` and `anthropic` |
> | `gen_ai.response.id`, `anthropic.request.id` | `anthropic.messages.create` | IDs of the response and the request |
> | `anthropic.message.stop_reason` | `anthropic.messages.create` | For example `end_turn` |
>
> The span also carries your Anthropic organization and workspace IDs in `anthropic.organization.id` and `anthropic.workspace.id`. It has no `ttft_ms` or `gen_ai.response.finish_reasons`. There are no `claude_code.tool` spans: a Go agent's tool calls are your own code, so run each tool as an Activity to get a `RunActivity` span for it. By default, the span contains no prompts or responses.

The Python and TypeScript agents run in Claude Code, so their model requests and tool calls are `claude_code.*` spans:

![Span details of a claude\_code.llm\_request span in Bronto, showing the model, input, output and cache tokens, time to first token and the stop reason](https://mintcdn.com/bronto/_Nx3BR7Rshe2zZlA/images/integrations/assets/images/temporal-claude-llm-request-span.png?fit=max\&auto=format\&n=_Nx3BR7Rshe2zZlA\&q=85\&s=e2ea9f2616259b572dfb3bc086c4a885)

A claude\_code.llm\_request span with model, token counts and time to first token

| Field | Spans | Notes |
| - | - | - |
| `gen_ai.request.model` | `claude_code.llm_request` | The model |
| `input_tokens`, `output_tokens` | `claude_code.llm_request` | Tokens of one request |
| `cache_read_tokens`, `cache_creation_tokens` | `claude_code.llm_request` | Prompt cache tokens |
| `ttft_ms` | `claude_code.llm_request` | Time to first token, in milliseconds |
| `gen_ai.response.finish_reasons.0` | `claude_code.llm_request` | For example `tool_use` or `end_turn` |
| `gen_ai.tool.name` | `claude_code.tool` | The tool, for example `mcp__demo__get_weather` |
| `gen_ai.conversation.id`, `session.id` | `claude_code.llm_request`, `claude_code.tool` | The Claude Code session. Search for it to find all spans of one agent run |

In the TypeScript run (Claude Code 2.1.332), `gen_ai.tool.name` was the tool name without the MCP prefix, `get_weather`. The prefixed name `mcp__demo__get_weather` was in `tool_name`.

By default, the spans contain no prompts, responses or tool arguments. For the settings that add them, see [Claude Code: Monitoring](https://code.claude.com/docs/en/monitoring-usage).

## Send Temporal SDK metrics

> [tab] Python
>
> The Temporal SDK has its own metrics exporter, separate from the OpenTelemetry Python SDK. It doesn't read the `OTEL_EXPORTER_OTLP_*` variables, so pass the endpoint and API key in code. The example reads the key from its own variable:
>
> ```bash theme={"dark"}
> export BRONTO_API_KEY="<YOUR_API_KEY>"
> ```
>
> Configure the exporter on a `Runtime` and pass the runtime to the client:
>
> ```python theme={"dark"}
> import os
> from datetime import timedelta
> from temporalio.client import Client
> from temporalio.contrib.opentelemetry import OpenTelemetryPlugin
> from temporalio.runtime import OpenTelemetryConfig, OpenTelemetryMetricTemporality, Runtime, TelemetryConfig
>
> runtime = Runtime(
>     telemetry=TelemetryConfig(
>         metric_prefix="temporal_",
>         metrics=OpenTelemetryConfig(
>             url="https://ingestion.eu.bronto.io/v1/metrics",
>             headers={"x-bronto-api-key": os.environ["BRONTO_API_KEY"]},
>             http=True,
>             metric_temporality=OpenTelemetryMetricTemporality.DELTA,
>             metric_periodicity=timedelta(seconds=60),
>         ),
>     )
> )
>
> client = await Client.connect(
>     "localhost:7233",
>     runtime=runtime,
>     plugins=[OpenTelemetryPlugin(add_temporal_spans=True)],
> )
> ```
>
> Differences from the OpenTelemetry SDK exporter:
>
> * Use the **full URL including `/v1/metrics`**. Unlike the OpenTelemetry SDK, it doesn't append the path.
> * Set `http=True`. The default is OTLP over gRPC.
> * Set the temporality to `DELTA`. With cumulative temporality, every export repeats the running total, and summing a counter in Bronto counts the same events more than once.
>
> It does read `OTEL_SERVICE_NAME` for the `service.name` resource attribute.

> [tab] TypeScript
>
> As in Python, the Temporal SDK has its own metrics exporter. It doesn't read the `OTEL_EXPORTER_OTLP_*` variables, so pass the endpoint and API key in code. The example reads the key from `BRONTO_API_KEY`:
>
> ```bash theme={"dark"}
> export BRONTO_API_KEY="<YOUR_API_KEY>"
> ```
>
> Install the runtime before you create the Worker or the client. It applies to the whole process:
>
> ```typescript theme={"dark"}
> import { Runtime } from '@temporalio/worker';
>
> Runtime.install({
>   telemetryOptions: {
>     metrics: {
>       metricPrefix: 'temporal_',
>       otel: {
>         url: 'https://ingestion.eu.bronto.io/v1/metrics',
>         http: true,
>         headers: { 'x-bronto-api-key': process.env.BRONTO_API_KEY! },
>         metricsExportInterval: '60s',
>         temporality: 'delta',
>       },
>     },
>   },
> });
> ```
>
> As in Python, use the **full URL including `/v1/metrics`**, set `http: true` and set `temporality: 'delta'`.
>
> The TypeScript exporter doesn't read `OTEL_SERVICE_NAME`. Its metrics arrive with the tag `service_name=temporal-core-sdk` and no `service.name`. To tell Workers apart, add your own tag with `globalTags`, for example `globalTags: { service: 'order-worker' }`, and group by it.

> [tab] Go
>
> The Go SDK reports metrics through a metrics handler on the client. The contrib package's handler wraps an OpenTelemetry meter, so it uses the OpenTelemetry Go SDK and reads the same `OTEL_EXPORTER_OTLP_*` variables as traces. The exporter appends `/v1/metrics`, and the SDK adds the `temporal_` prefix itself.
>
> ```bash theme={"dark"}
> go get go.opentelemetry.io/otel/sdk/metric \
>   go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp
> ```
>
> ```go theme={"dark"}
> import (
>     "time"
>
>     "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp"
>     sdkmetric "go.opentelemetry.io/otel/sdk/metric"
>     "go.opentelemetry.io/otel/sdk/metric/metricdata"
>     temporalotel "go.temporal.io/sdk/contrib/opentelemetry"
> )
>
> mexp, err := otlpmetrichttp.New(ctx, otlpmetrichttp.WithTemporalitySelector(
>     func(sdkmetric.InstrumentKind) metricdata.Temporality { return metricdata.DeltaTemporality }))
> if err != nil {
>     log.Fatal(err)
> }
> mp := sdkmetric.NewMeterProvider(sdkmetric.WithResource(res),
>     sdkmetric.WithReader(sdkmetric.NewPeriodicReader(mexp, sdkmetric.WithInterval(60*time.Second))))
> defer mp.Shutdown(ctx)
>
> handler := temporalotel.NewMetricsHandler(temporalotel.MetricsHandlerOptions{
>     Meter:                mp.Meter("temporal-sdk-go"),
>     UseMonotonicCounters: true,
>     OnError:              func(err error) { log.Println("metrics:", err) },
> })
>
> c, err := client.Dial(client.Options{
>     HostPort:       "localhost:7233",
>     Interceptors:   []interceptor.ClientInterceptor{tracing},
>     MetricsHandler: handler,
> })
> ```
>
> * Set the temporality to delta, as in Python. With cumulative temporality, summing a counter in Bronto counts the same events more than once.
> * `UseMonotonicCounters` exports the SDK's counters as monotonic sums.
> * Without `OnError`, the handler panics when the meter returns an error.
> * Call `mp.ForceFlush(ctx)` and `mp.Shutdown(ctx)` before a short-lived process exits, so the last interval is exported.

The metrics appear in [Metrics Explorer](https://docs.bronto.io/metrics/explore-metrics.md) with the `temporal_` prefix. Useful ones:

| Metric | What it measures | Group by |
| - | - | - |
| `temporal_workflow_completed`, `temporal_workflow_failed` | Workflows that completed or failed | `workflow_type`, `task_queue` |
| `temporal_workflow_endtoend_latency` | Time from Workflow start to completion | `workflow_type`, `task_queue` |
| `temporal_activity_execution_failed` | Failed Activity attempts, including attempts that are retried | `activity_type`, `workflow_type`, `task_queue` |
| `temporal_activity_execution_latency` | Time an Activity attempt took to run | `activity_type`, `workflow_type`, `task_queue` |
| `temporal_activity_schedule_to_start_latency`, `temporal_workflow_task_schedule_to_start_latency` | Time tasks waited in the Task Queue. A rising value means you need more Workers | `task_queue` |
| `temporal_worker_task_slots_available`, `temporal_worker_task_slots_used` | Worker capacity | `task_queue`, `worker_type` |
| `temporal_request`, `temporal_request_latency` | Calls from the SDK to the Temporal Service | `operation` |

![Bronto Metrics Explorer showing temporal\_activity\_execution\_failed as a sum grouped by activity\_type, with one failure for charge\_card](https://mintcdn.com/bronto/_Nx3BR7Rshe2zZlA/images/integrations/assets/images/temporal-activity-failed-metric.png?fit=max\&auto=format\&n=_Nx3BR7Rshe2zZlA\&q=85\&s=8338d3cc6dd22a5f2412d9fc42bbcefe)

temporal\_activity\_execution\_failed grouped by activity\_type

All of them also carry `namespace`. For the full list of metrics and their tags, see the [Temporal SDK metrics reference](https://docs.temporal.io/references/sdk-metrics).

The TypeScript and Go SDKs emit the same metric names. Their `workflow_type` and `activity_type` values are the function names, for example `chargeCard` in TypeScript. Go keeps Go casing, for example `ChargeCard`.

Latency metrics are in milliseconds in Python and TypeScript, and in seconds in Go. A Workflow that ran 1.07 seconds has a `temporal_workflow_endtoend_latency` of `1.07` in Go. Keep this in mind when you compare Workers in different languages or set monitor thresholds.

## Alert on failures

[Monitors](https://docs.bronto.io/core-features/monitors.md) evaluate log datasets and metrics, not spans. Create a metric monitor on `temporal_workflow_failed` or `temporal_activity_execution_failed` with **Sum** over a time window, grouped by `workflow_type` or `activity_type`. A monitor on `temporal_activity_schedule_to_start_latency` tells you when Workers fall behind.

## Verify in Bronto

Start a Workflow, then open [Tracing](https://docs.bronto.io/tracing/explore-traces.md) and filter by the service names you configured. Each Workflow appears as a `StartWorkflow:<Workflow type>` operation. The Worker's spans can arrive a minute or two after the client's span. Then open [Metrics Explorer](https://docs.bronto.io/metrics/explore-metrics.md) and search for `temporal_`.

If the client's span appears but the Worker's spans don't, check that the Worker's client also has `OpenTelemetryPlugin` and a tracer provider registered before `Client.connect`. If no metrics appear, check the full `/v1/metrics` URL and `http=True`.

In TypeScript, check that the Worker passes `OpenTelemetryPlugin` to `Worker.create` and that `provider.register()` ran before the first Workflow. If no metrics appear, check the full `/v1/metrics` URL and `http: true`, and look for export errors in the Worker's log.

In Go, check that the Worker's client has the tracing interceptor and that you called `otel.SetTracerProvider` before you created the client. The Go exporters write errors to the standard `log` package. If a stray `OTEL_EXPORTER_OTLP_INSECURE=true` is set in the environment, they send plain HTTP to the endpoint and time out.

## References

* [LLM Observability](https://docs.bronto.io/ai-features/llm-observability.md)
* [Explore Traces](https://docs.bronto.io/tracing/explore-traces.md)
* [Temporal: Python SDK observability](https://docs.temporal.io/develop/python/platform/observability)
* [Temporal: TypeScript SDK observability](https://docs.temporal.io/develop/typescript/platform/observability)
* [Temporal: Go SDK observability](https://docs.temporal.io/develop/go/observability)
* [Temporal: SDK metrics reference](https://docs.temporal.io/references/sdk-metrics)
* [Temporal: Claude Agent SDK integration](https://docs.temporal.io/develop/python/integrations/claude-agent-sdk)
* [Claude Agent SDK for TypeScript](https://code.claude.com/docs/en/agent-sdk/typescript)
* [Anthropic Go SDK](https://github.com/anthropics/anthropic-sdk-go)
* [Claude Code: Monitoring](https://code.claude.com/docs/en/monitoring-usage)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.