Traces payload
Endpoint
POST https://ingress.flareapp.io/v1/traces
Headers
| Header | Value | Description |
|---|---|---|
Content-Type |
application/json |
Required |
Accept |
application/json |
Required |
x-api-token |
{apiToken} |
API token |
Authentication
Authenticate using your project's private API key in the x-api-token header. The public API key cannot be used for this endpoint.
Payload
The trace payload follows the OTLP JSON encoding. Fields that have their default value may be left out, and 64 bit numbers such as the nanosecond timestamps may be sent as decimal strings. This means a payload from a stock OpenTelemetry exporter is accepted as is.
| Field | Type | Validation | Description |
|---|---|---|---|
resourceSpans |
array | required, non-empty | Array of resource span objects |
Resource Spans
| Field | Type | Validation | Description |
|---|---|---|---|
resource |
object | required | The resource producing these spans |
scopeSpans |
array | required, non-empty | Array of scope span objects |
Resource
A resource represents the entity producing telemetry data (your application/service). For a list of common resource attributes, see Resources.
| Field | Type | Validation | Description |
|---|---|---|---|
attributes |
array | required | OTEL-format key-value pairs |
droppedAttributesCount |
int | optional | Number of dropped attributes (defaults to 0) |
Scope Spans
| Field | Type | Validation | Description |
|---|---|---|---|
scope |
object | required | The instrumentation scope |
spans |
array | required, non-empty | Array of span objects |
Scope
A scope represents the instrumentation library that produced the spans. Different libraries (e.g. your Flare client, a database recorder, a cache recorder) can each be their own scope within the same resource.
| Field | Type | Validation | Description |
|---|---|---|---|
name |
string | required, non-empty | Instrumentation scope name |
version |
string/number | optional | Instrumentation scope version |
attributes |
array | optional | OTEL-format key-value pairs |
droppedAttributesCount |
int | optional | Number of dropped attributes |
Spans
A span represents a single unit of work within a trace, such as an HTTP request, a database query, or a cache operation. Each span has a start time, an end time, and optional attributes that describe the work being done. Spans can be nested using parentSpanId to form a tree structure that represents the full execution flow of a request.
| Field | Type | Validation | Description |
|---|---|---|---|
traceId |
string | required, non-empty | Trace identifier (32 lowercase hex characters) |
spanId |
string | required, non-empty | Span identifier (16 lowercase hex characters) |
parentSpanId |
string/null | optional | Parent span identifier. Leave it out, or send null or an empty string, for a root span |
name |
string | required, non-empty | Human-readable span name |
startTimeUnixNano |
int/string | required | Start time in nanoseconds |
endTimeUnixNano |
int/string | required | End time in nanoseconds |
kind |
int | optional | OpenTelemetry span kind (defaults to 0, unspecified) |
flags |
int | optional | OpenTelemetry span flags (defaults to 0) |
status |
object | optional | Span status (defaults to unset) |
attributes |
array | optional | OTEL-format attributes |
droppedAttributesCount |
int | optional | Number of dropped attributes (defaults to 0) |
events |
array | optional | Array of span event objects (defaults to an empty array) |
droppedEventsCount |
int | optional | Number of dropped events (defaults to 0) |
A parentSpanId may point at a span that is not in the same payload. Flare stores every span and builds the trace tree when you open the trace. A span whose parent never arrives shows up as its own root. This is how a job links back to the request that dispatched it.
Span Status
| Field | Type | Validation | Description |
|---|---|---|---|
code |
int | optional | Status code (defaults to 0) |
message |
string/null | optional | Status message |
Status Codes
| Code | Name | Description |
|---|---|---|
0 |
Unset | Default, no explicit status set |
1 |
Ok | Manually set by developer to indicate success |
2 |
Error | An error occurred during the span |
Span Events
Span events are nested inside their parent span. For the full list of span types and span event types with their attributes, see Events.
| Field | Type | Validation | Description |
|---|---|---|---|
name |
string | required, non-empty | Event name |
timeUnixNano |
int/string | required | Event timestamp in nanoseconds |
attributes |
array | optional | OTEL-format attributes |
droppedAttributesCount |
int | optional | Number of dropped attributes (defaults to 0) |
Span & Span Event Types
The span type is the flare.span_type attribute when you send it. Flare stores the value you sent as the span type. Flare also derives a category from the type and returns it as type_category next to the type in the trace API. Every type belongs to exactly one of these twelve categories.
| Category | Span types |
|---|---|
request |
php_request, request |
query |
php_query, redis_command, query |
http_client |
php_http_request, browser_fetch, browser_xhr, http_client |
command |
php_command, command |
job |
laravel_job, php_job, job |
producer |
laravel_queueing, producer |
view |
php_view, view |
function |
operation, function |
application |
php_application, php_application_registration, php_application_boot, php_application_terminating |
browser_page |
browser_pageload, browser_navigation, browser_web_vital |
livewire_component |
laravel_livewire_component and its phases (mounting, hydrating and so on) |
other |
every type not listed above, such as unknown, php_routing, the middleware types, php_controller, php_response, php_transaction, php_filesystem, php_notification and browser_component |
When you do not send flare.span_type, Flare infers a generic type from the span kind and the OpenTelemetry semantic convention attributes: request, query, http_client, job, producer, operation (a root span no rule recognizes) or function. Any other span gets unknown. command and view are never inferred, so send them with flare.span_type. For the values of the Flare SDKs, see Events.
The span event type is determined by the flare.span_event_type attribute on the span event.
Entry Point
We recommend adding flare.entry_point.* attributes to the root entry span of a trace. They are not required. They describe the request, command, job, or browser page that the trace represents. The same attributes are used by errors and logs. See Entry points for the schema and per-scenario examples.
Attribute Format
All attributes in the traces endpoint use the OpenTelemetry typed attribute format. See Attribute Formats for the full format specification and value types.
Responses
All responses include CORS headers (Access-Control-Allow-Origin: *) and return application/json.
| Status | Description |
|---|---|
201 |
Trace accepted |
403 |
Invalid API key |
405 |
HTTP method not allowed (only POST is accepted) |
401 |
Missing API key |
422 |
Validation error (missing resourceSpans, missing traceId or spanId) |
429 |
Rate limit or trace quota exceeded |
Success response:
JSON
{}
Validation error responses include the field path and a description of the issue:
JSON
{
"message": "The given data was invalid.",
"errors": {
"resourceSpans.0.scopeSpans.0.spans.0.traceId": [
"The first span requires traceId as a string"
]
}
}
Example
JSON
{
"resourceSpans": [
{
"resource": {
"attributes": [
{ "key": "service.name", "value": { "stringValue": "My Application" } },
{ "key": "service.version", "value": { "stringValue": "1.0.0" } },
{ "key": "service.stage", "value": { "stringValue": "production" } },
{ "key": "telemetry.sdk.language", "value": { "stringValue": "PHP" } },
{ "key": "telemetry.sdk.name", "value": { "stringValue": "spatie/flare-client-php" } },
{ "key": "telemetry.sdk.version", "value": { "stringValue": "1.0.0" } }
],
"droppedAttributesCount": 0
},
"scopeSpans": [
{
"scope": {
"name": "spatie/laravel-flare",
"version": "1.0.0"
},
"spans": [
{
"traceId": "a1b2c3d4e5f67890a1b2c3d4e5f67890",
"spanId": "1234567890abcdef",
"parentSpanId": null,
"name": "GET /users",
"startTimeUnixNano": 1710252000000000000,
"endTimeUnixNano": 1710252000150000000,
"status": { "code": 0 },
"attributes": [
{ "key": "flare.span_type", "value": { "stringValue": "php_request" } },
{ "key": "http.request.method", "value": { "stringValue": "GET" } },
{ "key": "http.route", "value": { "stringValue": "/users" } },
{ "key": "http.response.status_code", "value": { "intValue": 200 } }
],
"droppedAttributesCount": 0,
"events": [
{
"name": "cache hit",
"timeUnixNano": 1710252000050000000,
"attributes": [
{ "key": "flare.span_event_type", "value": { "stringValue": "php_cache" } },
{ "key": "cache.operation", "value": { "stringValue": "get" } },
{ "key": "cache.result", "value": { "stringValue": "hit" } },
{ "key": "cache.key", "value": { "stringValue": "users.list" } }
]
}
],
"droppedEventsCount": 0
},
{
"traceId": "a1b2c3d4e5f67890a1b2c3d4e5f67890",
"spanId": "abcdef1234567890",
"parentSpanId": "1234567890abcdef",
"name": "select * from `users`",
"startTimeUnixNano": 1710252000060000000,
"endTimeUnixNano": 1710252000080000000,
"status": { "code": 0 },
"attributes": [
{ "key": "flare.span_type", "value": { "stringValue": "php_query" } },
{ "key": "db.system", "value": { "stringValue": "mysql" } },
{ "key": "db.statement", "value": { "stringValue": "select * from `users`" } }
],
"droppedAttributesCount": 0,
"events": [],
"droppedEventsCount": 0
}
]
}
]
}
]
}
On this page