OpenTelemetry
Submit existing OpenTelemetry spans to SuperPenguin for cost attribution.
This page describes the in-process SDK OTel helper: application code calls submitSpan(), which converts one span into a SuperPenguin SDK event.
import { submitSpan } from "@superpenguin/js";
await submitSpan(span, {
metadata: {
environment: "production",
feature: "support_agent",
},
});Vercel AI SDK telemetry fields (functionId) and OpenTelemetry trace IDs are stored under custom_tags unless they map to a first-class attribution column.
For a provider or standard exporter that should POST OTLP/HTTP JSON directly, use the separate hosted OpenTelemetry endpoint. Do not send an OTLP envelope to /api/sdk/ingest, and do not call both paths for the same generation unless they share a provider response ID.
Python correlation
Install the optional extra and keep an active OTel span around wrapped calls:
pip install "superpenguin[otel]"When a span is active, the Python SDK stores trace_id, span_id, traceparent, and otel_scope under custom_tags. @sp.trace also stores superpenguin_trace_id for correlation.
Configuration reference (TypeScript)
init()
| Parameter | Default | Description |
|---|---|---|
apiKey | SP_API_KEY | SuperPenguin key |
baseUrl | https://app.superpenguin.ai | API endpoint |
flushMode | "immediate" | Use "interval" for long-lived workers |
batchSize | 50 | Max events per POST |
flushIntervalMs | 5000 | Interval flush cadence |
maxRetries | 2 | Transient failure retries |
throwOnError | false | Propagate ingest errors |
keepalive | true | fetch keepalive for serverless |
Call await flush() before shutting down interval-mode workers.