New to distributed tracing?
Start with our Introduction to Tracing for an overview of how to explore your traces in Better Stack.
Better Stack ingests trace data using the OpenTelemetry Protocol (OTLP), the open standard for telemetry data. This allows you to send distributed traces from your applications and services to gain deep visibility into your system's behavior.
For the easiest setup, we recommend using the Better Stack collector, which provides zero-code auto-instrumentation for Kubernetes and Docker.
Start with our Introduction to Tracing for an overview of how to explore your traces in Better Stack.
Headers
Either application/json or application/x-protobuf.
Bearer $SOURCE_TOKEN
Body parameters
A batch of spans structured according to the OpenTelemetry Protocol (OTLP) specification.
The trace data was successfully received.
Response body
You provided an invalid source token.
Response body
Traces are sent as a batch of spans. The root of the payload is a JSON object containing a resourceSpans array. Each item in this array represents spans from a specific resource (like a service or application).
Each span represents a single operation within a trace.
| Field | Format | Length | Description |
|---|---|---|---|
traceId |
Hexadecimal string | 32 chars (16 bytes) | A unique identifier for the entire trace. All spans in a trace share the same traceId. |
spanId |
Hexadecimal string | 16 chars (8 bytes) | A unique identifier for the span. |
parentSpanId |
Hexadecimal string | 16 chars (8 bytes) | The spanId of the parent span. If this field is empty or missing, the span is a root span. |
Our ingestion service accepts IDs as either Base64-encoded binary (as per the OTLP protobuf specification) or direct hexadecimal strings (for non-conformant senders). For OTLP/JSON, use hex strings.
To get the most out of tracing, you can correlate your traces with logs. This allows you to jump from a specific span directly to the logs that were generated during that operation, providing full context for debugging.
To enable automatic correlation, ensure that your logs and traces include the same span.trace_id and span.span_id fields, and are sent to the same Better Stack source.
When you send a log event via the HTTP REST API for logs, you can include the trace context like this:
Timestamps are provided in nanoseconds since the Unix epoch.
| Field | Format | Example |
|---|---|---|
startTimeUnixNano |
Unix nanoseconds (string) | "1738316288153703000" |
endTimeUnixNano |
Unix nanoseconds (string) | "1738316288208088000" |
The duration of a span is calculated upon ingestion as (endTimeUnixNano - startTimeUnixNano).
Spans without an endTimeUnixNano are considered in-progress and are skipped during ingestion.
name: A human-readable string for the operation (e.g., "GET /api/users").kind: An integer that specifies the type of operation.| Integer | Kind | Description |
|---|---|---|
1 |
INTERNAL |
An internal operation within an application. |
2 |
SERVER |
A request handled by a server. |
3 |
CLIENT |
A request made by a client. |
4 |
PRODUCER |
A message sent to a messaging queue. |
5 |
CONSUMER |
A message received from a messaging queue. |
The maximum allowed size of a single request, which may contain many spans, is 10 MiB of compressed data.
There is no limit to the number of requests you can send.
We use cookies to authenticate users, improve the product user experience, and for personalized ads. Learn more.