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

# OpenTelemetry

> Send traces, metrics, and logs from any OTel-instrumented service directly to AgentVista over OTLP/HTTP.

AgentVista accepts standard [OTLP/HTTP](https://opentelemetry.io/docs/specs/otlp/) for traces, metrics, and logs. If a service is already instrumented with OpenTelemetry, you can point it at AgentVista without writing any AgentVista-specific code.

<Note>
  AI agent spans recorded with the AgentVista SDK and infrastructure spans sent
  over OTLP appear together in a single unified trace. This is the core value of
  the platform: one view of what your agents and your infrastructure did during
  the same request.
</Note>

***

## Endpoints

| Signal  | Method | URL                                                 |
| ------- | ------ | --------------------------------------------------- |
| Traces  | `POST` | `https://api.agentvista.dev/api/v1/otlp/v1/traces`  |
| Metrics | `POST` | `https://api.agentvista.dev/api/v1/otlp/v1/metrics` |
| Logs    | `POST` | `https://api.agentvista.dev/api/v1/otlp/v1/logs`    |

All endpoints require an `Authorization: Bearer av_...` header.

The `service.name` resource attribute on each incoming payload is used to identify the service or agent in the AgentVista UI. Set it to a meaningful name so your services appear correctly in the service map and trace views.

***

## Configuration

<Tabs>
  <Tab title="OpenTelemetry SDK (Python)">
    Configure the OTLP exporter to point at AgentVista when you set up your
    tracer provider:

    ```python theme={null}
    from opentelemetry import trace
    from opentelemetry.sdk.trace import TracerProvider
    from opentelemetry.sdk.trace.export import BatchSpanProcessor
    from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
    from opentelemetry.sdk.resources import Resource

    resource = Resource.create({"service.name": "payments-api"})

    exporter = OTLPSpanExporter(
        endpoint="https://api.agentvista.dev/api/v1",
        headers={"Authorization": "Bearer av_xxxxx"},
    )

    provider = TracerProvider(resource=resource)
    provider.add_span_processor(BatchSpanProcessor(exporter))
    trace.set_tracer_provider(provider)
    ```

    From this point, any span created via `trace.get_tracer(__name__)` is
    automatically exported to AgentVista. No other changes to your service are
    needed.

    For metrics, use `OTLPMetricExporter` from
    `opentelemetry.exporter.otlp.proto.http.metric_exporter` with the same
    endpoint and headers. For logs, use `OTLPLogExporter` from
    `opentelemetry.exporter.otlp.proto.http._log_exporter`.
  </Tab>

  <Tab title="OpenTelemetry Collector">
    If you already run an OpenTelemetry Collector, add AgentVista as an
    `otlphttp` exporter in your pipeline:

    ```yaml theme={null}
    exporters:
      otlphttp/agentvista:
        endpoint: https://api.agentvista.dev/api/v1
        headers:
          Authorization: "Bearer av_xxxxx"

    service:
      pipelines:
        traces:
          receivers: [otlp]
          processors: [batch]
          exporters: [otlphttp/agentvista]
        metrics:
          receivers: [otlp]
          processors: [batch]
          exporters: [otlphttp/agentvista]
        logs:
          receivers: [otlp]
          processors: [batch]
          exporters: [otlphttp/agentvista]
    ```

    You can keep existing exporters (e.g. to Prometheus or Grafana) in the same
    pipeline alongside AgentVista.
  </Tab>
</Tabs>

***

## Correlating agents with infrastructure

When both the AgentVista SDK and OTLP data flow into the platform, traces can span your entire stack in a single waterfall view — from the user request through the agent orchestrator, through every LLM call, all the way down to the database query that determined the result.

<Tip>
  Once you have both sources flowing, open any agent trace in the AgentVista
  dashboard and look for the correlated infrastructure spans. You can follow a
  slow agent run directly to the downstream service or database query that
  caused it — without switching tools or correlating timestamps by hand.
</Tip>

### How correlation works

The AgentVista SDK injects a [W3C `traceparent`](https://www.w3.org/TR/trace-context/) header on outbound requests via `agentvista.inject_traceparent(headers)`. Any downstream service instrumented with standard OpenTelemetry will automatically propagate this header and include it in the spans it exports. When those OTLP spans arrive at AgentVista they are stitched into the same trace by `trace_id`.

```python theme={null}
import httpx
import agentvista

with agentvista.run("order-processor") as r:
    # Propagate the trace into the downstream payments service
    headers = {}
    agentvista.inject_traceparent(headers)

    response = httpx.post(
        "https://payments-api/charge",
        headers=headers,
        json={"amount": 99.00},
    )
    r.set_outcome(success=response.status_code == 200)
```

If the `payments-api` is instrumented with the OpenTelemetry Python SDK (or any OTel-compatible library), its spans automatically appear as children of the `order-processor` trace in AgentVista — no additional configuration needed.
