---
title: OpenTelemetry
description: Export DurableStack traces and metrics through OpenTelemetry.
order: 43
available_in: [dotnet, nodejs]
---

OpenTelemetry integration is runtime-specific.

In .NET, DurableStack integrates by registering its ActivitySource and Meter.

In Node.js, DurableStack runtime events can be bridged into your existing OpenTelemetry pipeline.

Use this when you want traces/metrics to flow into your existing OpenTelemetry pipeline.

## .NET helper: `AddDurableStackOpenTelemetry`

- Adds DurableStack tracing source to OpenTelemetry.
- Adds DurableStack metrics meter to OpenTelemetry.
- Leaves exporter selection to your app's OTel setup.

## Example

:::code-group
```csharp
using DurableStack.Hosting.DependencyInjection;

builder.Services.AddDurableStackPostgres(connectionString, options =>
{
    options.WorkerName = $"orders-api-{Environment.MachineName}-{Environment.ProcessId}";
});

builder.Services.AddDurableStackOpenTelemetry();
```

```typescript
import { createDurableStackPostgres } from "durablestack";

const { runtime } = await createDurableStackPostgres(
  { connectionString: process.env.DATABASE_URL! },
  {
    workerName: `orders-api-${process.pid}`
  }
);

// DurableStack emits runtime events that can be bridged to your OpenTelemetry pipeline.
// Wire your event sink to your OTel SDK/exporter of choice.
```
:::

## Integration guidance

- Keep resource attributes (`service.name`, environment) consistent across services.
- Use traces to correlate run failures with downstream dependency calls.
- Use metrics for alerting on claims, failures, retries, and lease extensions.

## Notes

- OpenTelemetry integration is optional.
- It complements event sinks and hosted observability rather than replacing them.
