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

# Traces

> Send OpenTelemetry traces to your infrastructure's built-in trace store and follow a request across services.

Every infrastructure has a trace store, Tempo, and an OpenTelemetry endpoint on every node, ready to receive. Your services send traces with the OpenTelemetry SDK for their language, and you read them in the console as a waterfall of spans.

## Send traces

Point your OpenTelemetry SDK at the in-cluster endpoint:

| Protocol | Endpoint |
| - | - |
| OTLP over HTTP | `http://alloy.monitoring.svc.cluster.local:4318` |
| OTLP over gRPC | `http://alloy.monitoring.svc.cluster.local:4317` |

The simplest way is with the standard OpenTelemetry environment variables in [`inframan.yaml`](https://inframan.mintlify.site/deploy/inframan-yaml):

```yaml inframan.yaml theme={null}
services:
  api:
    port: 8080
    env:
      OTEL_SERVICE_NAME: api
      OTEL_EXPORTER_OTLP_ENDPOINT: http://alloy.monitoring.svc.cluster.local:4318
      OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
```

> [!WARNING]
>
> Set the service name to the service's name in `inframan.yaml`. Inframan finds a service's traces by matching it, so traces sent under another name won't show up for the service.

Then turn on tracing in your code. Automatic instrumentation covers HTTP servers and clients, database drivers and most popular frameworks:

> [tab] Node.js
>
> ```bash theme={null}
> npm install @opentelemetry/api @opentelemetry/auto-instrumentations-node
> ```
>
> Start your app with the instrumentation loaded:
>
> ```yaml inframan.yaml theme={null}
> services:
>   api:
>     start_command: node --require @opentelemetry/auto-instrumentations-node/register dist/server.js
> ```

> [tab] Python
>
> ```bash theme={null}
> pip install opentelemetry-distro opentelemetry-exporter-otlp
> opentelemetry-bootstrap -a install
> ```
>
> Start your app through the instrumentation wrapper:
>
> ```yaml inframan.yaml theme={null}
> services:
>   api:
>     start_command: opentelemetry-instrument gunicorn app:app --bind 0.0.0.0:8080
> ```

> [tab] Other languages
>
> Use your language's OpenTelemetry SDK with an OTLP exporter. The environment variables above are read by every official SDK. See the [OpenTelemetry documentation](https://opentelemetry.io/docs/languages/).

Tracing is opt-in on purpose. Your SDK decides what's traced and how much is sampled, and nothing is added to your services that you didn't choose.

## Read traces

Open **Observability**, select **Applications**, then **Traces**. **Distributed Traces** lists recent traces for the selected services. Select one to open its **Trace Waterfall**:

* The trace's **Trace ID**, total **Duration**, number of **Spans** and the **Services** it crossed.
* One bar per span, sized by its duration relative to the whole trace, so the slow step stands out.

A log line with a `trace_id` field opens its trace directly. See [Logs](https://inframan.mintlify.site/monitor/logs.md#jump-from-a-log-line-to-its-trace).

## How long traces are kept

24 hours on a non-production infrastructure.

## Traces for an AI assistant

A connected assistant can search a service's recent traces, over up to 7 days, and open any trace by its ID. It gets the spans in order, with their HTTP, RPC, database and exception details, and the spans that failed, which makes it good at finding where a slow or failing request went wrong.


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