---
title: OpenTelemetry
description: Export DurableStack traces and metrics through OpenTelemetry.
order: 43
---

# OpenTelemetry

DurableStack integrates with OpenTelemetry by registering its activity source and meter.

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

## What `AddDurableStackOpenTelemetry` does

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

## Example

```csharp
using DurableStack.Hosting.DependencyInjection;

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

builder.Services.AddDurableStackOpenTelemetry();
```

## 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.
