# OpenTelemetry push

Already exporting OpenTelemetry GenAI spans? Point your exporter or Collector at the control plane instead of installing an SDK.

If your agent already records its model calls as OpenTelemetry spans in the [GenAI semantic conventions](https://opentelemetry.io/docs/specs/semconv/gen-ai/), with message content, point its OTLP exporter or your Collector at the control plane. Nothing to install.

## Push or SDK?

| Push spans when | Use an SDK when |
| --- | --- |
| The agent is already instrumented with OpenTelemetry | You also want practice tasks: generated tasks your agent works through and that are graded |
| The SDK can't be installed where the agent runs | You want the approved model and prompt applied for you (Node) or handed back (Python) |

Send each conversation one way only. Pushed spans and uploaded turns are both kept, so the same traffic sent both ways is learned from twice.

> **Note:**
> 
> Many instrumentations record message content only when you switch it on. Without it there is nothing to learn from.

## 1\. Add the agent

In the dashboard: **New mission** → **Your AI agent** → **Also send us the traces your agent already exports** → name the agent → **Create agent and get my key**. This registers the agent, gives it a `pefw_` key, opens its **Permissions** step, and shows its endpoint.

Turn on both permissions (conversations, and message text). Until both are on, every push is answered `403` and nothing in it is read.

Registering over the API instead, for an agent that never runs an SDK:

```bash
curl -X POST "$PERCEPTEYE_CONTROL_PLANE_URL/agents" \
  -H "Authorization: Bearer $PERCEPTEYE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"agent_id": "support-agent", "mode": "production", "discovered_agent": null}'
```

## 2\. Point your exporter at it

```text
POST $PERCEPTEYE_CONTROL_PLANE_URL/agents/<agent_id>/otlp/v1/traces
Authorization: Bearer pefw_...
```

### OpenTelemetry SDK exporter

```bash
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="$PERCEPTEYE_CONTROL_PLANE_URL/agents/support-agent/otlp/v1/traces"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="Authorization=Bearer%20$PERCEPTEYE_API_KEY"
export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf
```

`%20` is the space: OpenTelemetry reads these headers URL-encoded.

### OpenTelemetry Collector

```yaml
exporters:
  otlphttp/percepteye:
    traces_endpoint: ${env:PERCEPTEYE_CONTROL_PLANE_URL}/agents/support-agent/otlp/v1/traces
    headers:
      Authorization: "Bearer ${env:PERCEPTEYE_API_KEY}"
    sending_queue:
      num_consumers: 1
service:
  pipelines:
    traces:
      exporters: [otlphttp/percepteye]
```

`num_consumers: 1` avoids `429`s from a Collector sending several requests at once.

## 3\. See it arrive

The agent's **Agent** tab counts the spans pushed, beside turns uploaded by an SDK, and how many of each are kept but not learned from, and why.

## What the endpoint accepts and answers

| Status | Meaning | Retry? |
| --- | --- | --- |
| `200` | `ExportTraceServiceResponse`; `partial_success` counts spans not kept and says why | — |
| `400` | Not an OTLP trace export | No |
| `403` | Consent not given (`production_capture_not_enabled`, `model_content_capture_not_enabled`), or the key belongs to another agent | No |
| `415` | Send `application/x-protobuf` or `application/json`, gzip or uncompressed | No |
| `429` | Your organization is over its rate; `Retry-After` set | Yes, automatically |
| `503` | Control plane busy; `Retry-After` set | Yes, automatically |
| `507` | Request too large for this host's disk | No |

There is no size cap. Batches, as the batch processor and Collector send by default, are learned from soonest.

## Personal data

Message content is scanned for personal data. A request whose spans hold any is kept and excluded from training, and `partial_success` says so. Spans carrying an SDK rollout marker (`percepteye.rollout.id`) are rejected: practice tasks reach the control plane through the SDK.

## Exporting from the SDKs

The SDKs can also emit into your own tracing:

-   **Python:** `pip install "agent-flywheel[otel]"` emits each outcome as a span into your registered `TracerProvider` (the API only; it never installs an SDK). Spans carry the GenAI conventions plus `percepteye.tool.outcome`; an `unknown` leaves the span status unset.
-   **Node:** `@opentelemetry/api` is an optional peer dependency, used through `@percepteye/agent-flywheel/tracing`.

---
Source: https://docs.percepteye.ai/#guides-opentelemetry-push · Index: https://docs.percepteye.ai/llms.txt
