Skip to main content
Apgar accepts OpenTelemetry traces at POST /v1/traces. Any SDK or collector that exports OTLP over HTTP can send to it. Instrumentations that follow the OpenTelemetry GenAI semantic conventions or OpenInference work without changes.

Create an ingest token

An ingest token has the form apg_ing_ followed by 32 characters. Apgar shows it once and stores only its hash. There are two ways to get one:
  • Add agent with the OTLP source creates a token named AGENT (auto) and bound to that agent. Every trace sent with it belongs to that agent, whatever its attributes say.
  • Settings, Ingest tokens creates a token that you can bind to an agent or leave unbound. With an unbound token, Apgar resolves the agent from the agent name attributes, and the first trace with a new name creates the agent. Turn off Create agents automatically on the token to drop traces of unknown agents instead. An agent created this way has no environment and no Release attribute, so it reads the release from apgar.release, gen_ai.agent.version, or langfuse.release; set both in Agent settings. One unbound token can serve several agents.
Deleting a token revokes it. The API caches token lookups for 60 seconds, so a revoked token can still be accepted for up to a minute.

Configure the exporter

Set these variables in the environment of the agent service. ORIGIN is the address of the Apgar UI, the value of APGAR_PUBLIC_URL. The UI forwards /v1 to the API.
The snippet that Add agent shows contains the first three lines plus the agent name and environment. Add the release yourself: RELEASE is the identifier of the running build, a version, a tag, or a commit hash, and comes from your deploy pipeline. Put it in the attribute you chose as Release attribute on the agent; apgar.release is the usual choice. Without it every turn is stored as untagged and is never evaluated. See Release.

What a trace should look like

Apgar treats one trace as one turn of the agent. It works best when a trace has:
  • A root span for the turn, such as an invoke_agent or invoke_workflow span, carrying the conversation id. See Sessions.
  • One chat span per LLM call, with the model, token counts, and ideally a cost.
  • One tool span per tool call, with the tool name and its arguments.
Span kinds are read from gen_ai.operation.name, openinference.span.kind, or langfuse.observation.type. Set apgar.kind to override the kind of a span. See Span kinds.
Tool arguments are needed to detect retries and loops. Apgar never stores them: it keeps only a keyed hash. Content attributes are reduced to a length and a JSON validity flag and then dropped.

Example with the Python SDK

The OTLP exporter reads the variables above. The application opens one root span per turn and puts the conversation id on it; the chat and tool spans come from the instrumentation of your LLM client or agent framework.

Endpoint

Apgar accepts OTLP over HTTP only. An SDK that exports OTLP/gRPC switches to HTTP with OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf.

Send through an OpenTelemetry Collector

When traces already pass through a collector, add an exporter for Apgar next to the existing one. The application keeps exporting to the collector, and the collector sends a copy to Apgar. Each exporter has its own queue and retries, so an unavailable Apgar does not hold back your existing backend.
collector.yaml
In an existing collector only otlp_http/apgar and its entry in the traces pipeline are new. Set endpoint to APGAR_PUBLIC_URL; the exporter appends /v1/traces. Set APGAR_INGEST_TOKEN in the environment of the collector. Collector releases before the component rename know the exporters as otlphttp and otlp; current releases accept both spellings. Validate the configuration before you deploy it:
Put the Apgar exporter in a pipeline without sampling. A tail sampling policy that keeps only errors changes the error, retry, and loop rates that Apgar compares, and sampling by trace removes turns from sessions.

Check that traces arrive

Open the agent page. A trace becomes a turn about a minute after its last span arrives, and its release then appears in the release list, whose turn counts update every 5 minutes. When the parent of your top span belongs to a service that does not send to Apgar, a trace waits 10 minutes from its first span instead. The page warns when more than 5 % of turns have no release, which means the release attribute is missing on some traffic or the agent reads a different attribute. When nothing arrives, see Troubleshooting.