Framework guide

OpenTelemetry

Send traces to supatrace.dev over OTLP/HTTP with a stock Python or Node exporter. Protobuf or JSON. No gRPC, metrics or logs.

OTLP/HTTP ingest Live

SupaTrace accepts OpenTelemetry traces at POST /v1/traces on supatrace.dev. Any OTLP/HTTP exporter works with two environment variables and an ingest key. No SupaTrace package is needed.

Create an ingest key on Home or the API keys page. Ingest keys from Home or API keys do not expire by default; keys from pairing an agent last 30 days. In a fresh shell, set these two variables, replacing only YOUR_INGEST_KEY:

export OTEL_EXPORTER_OTLP_ENDPOINT=https://supatrace.dev
export OTEL_EXPORTER_OTLP_HEADERS="x-supatrace-key=YOUR_INGEST_KEY"

Both x-supatrace-key: <key> and Authorization: Bearer <key> are accepted. The environment-variable alternative is OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer YOUR_INGEST_KEY". Some SDKs require the space URL-encoded: Authorization=Bearer%20YOUR_INGEST_KEY, following the OpenTelemetry header format.

Try HTTP/JSON

This fake span calls no model provider. Replace the key before sending:

curl -X POST https://supatrace.dev/v1/traces \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_INGEST_KEY' \
  -d '{"resourceSpans":[{"scopeSpans":[{"spans":[{"traceId":"11111111111111111111111111111111","spanId":"1111111111111111","name":"synthetic.example","startTimeUnixNano":"1794685870000000000","endTimeUnixNano":"1794685871000000000"}]}]}]}'
# Or replace Authorization with: -H 'x-supatrace-key: YOUR_INGEST_KEY'

The base URL makes both stock exporters append /v1/traces. Leave any OTEL_EXPORTER_OTLP_TRACES_ENDPOINT and OTEL_EXPORTER_OTLP_TRACES_HEADERS overrides unset.

Python

pip install opentelemetry-sdk opentelemetry-exporter-otlp-proto-http

Save as first-trace.py. It sends one synthetic span over HTTP/protobuf and flushes before exit.

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter

provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))
trace.set_tracer_provider(provider)
with trace.get_tracer("first-trace-example").start_as_current_span("synthetic.chat") as span:
    span.set_attribute("gen_ai.provider.name", "example")
    span.set_attribute("gen_ai.request.model", "synthetic-model")
    print("Trace: otlp." + format(span.get_span_context().trace_id, "032x"))
provider.force_flush()
provider.shutdown()
python first-trace.py

JavaScript / Node 22

npm install @opentelemetry/sdk-trace-base@2.12.1 @opentelemetry/exporter-trace-otlp-http@0.223.2 @opentelemetry/api@1.9.1

These compatible package versions keep the trace SDK and exporter on the same OpenTelemetry API version. Save as first-trace.mjs (ESM). This JavaScript exporter reads the same two environment variables and appends /v1/traces to the base URL. It sends HTTP/JSON.

import { trace } from "@opentelemetry/api";
import { BasicTracerProvider, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";

const provider = new BasicTracerProvider({
  spanProcessors: [new SimpleSpanProcessor(new OTLPTraceExporter())],
});
trace.setGlobalTracerProvider(provider);
const span = trace.getTracer("first-trace-example").startSpan("synthetic.chat");
span.setAttribute("gen_ai.provider.name", "example");
span.setAttribute("gen_ai.request.model", "synthetic-model");
console.log("Trace: otlp." + span.spanContext().traceId);
span.end();
await provider.forceFlush();
await provider.shutdown();
node first-trace.mjs

Open Traces in the workspace and find the printed otlp.<traceid> run. These examples call no model provider.

  • Encoding: protobuf or JSON, with or without gzip. gRPC is not supported.
  • Size: 512 KiB per request on the wire, 2000 spans and 50 traces per export, 32 KiB stored per span.
  • Storage: each trace becomes a run named otlp.<traceid>. Each span becomes an event. Retried exports store nothing twice.

SDK availability

The JavaScript package is not published to npm. See the quickstart.

With mode="otlp" the SDKs send POST <SUPATRACE_OTLP_ENDPOINT>/v1/traces with the write key, only when the endpoint, the key and the OpenTelemetry packages are all present. The SDKs have not been run against the receiver.

pip install "opentelemetry-sdk>=1.27" "opentelemetry-exporter-otlp-proto-http>=1.27"
export SUPATRACE_OTLP_ENDPOINT="https://supatrace.dev"   # SupaTrace SDK OTLP mode (Python Beta; JavaScript source only)
export SUPATRACE_API_KEY="YOUR_WRITE_KEY"
import supatrace

trace = supatrace.init(service="checkout", mode="otlp")
trace.span("checkout.step", {"cart.items": 3})
print(trace.capture["sending"], trace.capture["skipped"])
trace.close()
import { init } from "supatrace";

const trace = init("checkout", { mode: "otlp" });
trace.span("checkout.step", { "cart.items": 3 });
console.log(trace.capture.sending, trace.capture.skipped);
await trace.close().shutdown;

Without an endpoint nothing is sent or saved. In OTLP mode span returns an in-memory batch with no file, gone when the process exits. For a file you can review and upload, use source mode as in the quickstart. An endpoint in the environment alone never turns export on. mode="otlp" must be explicit.

Apps on a Langfuse SDK Beta

An app that uses a Langfuse SDK can send traces to SupaTrace by changing the host and keys. This is ingest only, not a Langfuse API. Score events sent through batch ingestion are stored as events on the trace. They are not aggregated or shown as scores. The scores endpoint, prompts, datasets and trace-reading APIs are not served and answer 404. Hosted routes answer. SDK acceptance receipts are local only, so this stays beta.

export LANGFUSE_HOST="https://supatrace.dev"        # LANGFUSE_BASEURL for the JS SDK
export LANGFUSE_PUBLIC_KEY="pk-supatrace"            # any non-empty value; not a credential
export LANGFUSE_SECRET_KEY="YOUR_WRITE_KEY"

Update events are stored as their own events. They are not merged into the observation they update. Tested with Langfuse JS SDK 3.39.2 and Python SDK 5.2.0. Other versions are untested.