OTel Ingest
StackSpend accepts OpenTelemetry (OTLP) telemetry from Claude Code and Claude-based agents, converting spans and metrics into estimated cost line items.
Who needs this guide
Most users connecting Claude don't need to read this. The StackSpend MCP server or provider setup handles OTel configuration automatically.
This guide is for teams building custom integrations or self-hosting agent infrastructure who need to configure their own OTLP exporter.
Supported providers and endpoints
Each provider has its own set of OTLP endpoints. Replace {connectionId} with the Connection ID from your provider detail page.
| Provider | Logs endpoint | Metrics endpoint | Traces endpoint |
|---|---|---|---|
| claude | /api/v1/public/ingest/otel/claude/{connectionId}/v1/logs | /v1/metrics | — |
| claude-code | /api/v1/public/ingest/otel/claude-code/{connectionId}/v1/logs | /v1/metrics | — |
All endpoints are hosted at https://ingest.stackspend.app. The metrics and traces paths shown above are appended to the provider-specific base path. Point your OTLP exporter at the collector root (the .../{connectionId} base) — most exporters, including Claude Code, append /v1/logs and /v1/metrics automatically.
Authentication
Requests are authenticated with a write-only StackSpend ingest key passed in the Authorization header as Bearer <key>. Generate one with the Generate ingest key button on the provider detail page — StackSpend creates a key with the usage:write scope and shows it once. The connectionId in the URL identifies which provider connection the telemetry belongs to.
Setup
Find your Connection ID
In StackSpend, go to Providers and open your Claude provider. The Connection ID is displayed on the provider detail page.
If you haven't created a provider yet, go to Providers → Add provider and select Claude Code. The Connection ID is generated on save.
Configure your OTLP exporter
Set the following environment variables in your agent or CI environment. Replace <connectionId> with the value from step 1 and <ingest-key> with the key you generated.
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.stackspend.app/api/v1/public/ingest/otel/claude/<connectionId> OTEL_EXPORTER_OTLP_PROTOCOL=http/json OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer <ingest-key>
Verify data is arriving
Run your agent and then check Providers → [your provider] in StackSpend. Cost data appears within approximately one hour of telemetry being received.
If no data appears after an hour, confirm the OTEL_EXPORTER_OTLP_ENDPOINT value matches the Connection ID on the provider detail page exactly.
How data is processed
When StackSpend receives OTLP telemetry it extracts token counts and model information from the spans and metrics. It then applies current model pricing to produce estimated cost line items, which appear in the Data Explorer and dashboard alongside costs from other providers.
Data appears within approximately one hour of ingest. Costs are estimates based on token counts and published pricing — they are not pulled from Anthropic or OpenAI billing APIs and may differ from your actual invoice.