Span Protocol

The SDK must implement a new "span v2" envelope item, which is used to emit spans to Sentry.

The envelope item header must contain the following properties:

Copied
{
  "type": "span",
  "item_count": 2,
  "content_type": "application/vnd.sentry.items.span.v2+json"
}

The envelope item payload must contain an items array with span one and up to 1000 span objects:

Copied
{
  "items": [
    {
      "trace_id": "6cf173d587eb48568a9b2e12dcfbea52",
      "parent_span_id": null,
      "span_id": "438f40bd3b4a41ee",
      "name": "GET /users",
      "status": "ok",
      "is_remote": true,
      "kind": "server",
      "start_timestamp": 1742921669.158209,
      "end_timestamp": 1742921669.180536,
      "attributes": {
        "sentry.release": {
          "type": "string",
          "value": "1.0.0"
        },
        "sentry.environment": {
          "type": "string",
          "value": "local"
        },
        "sentry.platform": {
          "type": "string",
          "value": "php"
        },
        "sentry.sdk.name": {
          "type": "string",
          "value": "sentry.php"
        },
        "sentry.sdk.version": {
          "type": "string",
          "value": "4.10.0"
        },
        "sentry.transaction_info.source": {
          "type": "string",
          "value": "route"
        },
        "sentry.origin": {
          "type": "string",
          "value": "auto"
        },
        "server.address": {
          "type": "string",
          "value": "127.0.0.1"
        },
        "http.response.status_code": {
          "type": "integer",
          "value": 200
        },
        "links": [
          {
            "span_id": "6c71fc6b09b8b716",
            "trace_id": "627a2885119dcc8184fae7eef09438cb",
            "sampled": true,
            "attributes": {
              "sentry.link.type": {
                "type": "string",
                "value": "previous_trace"
              }
            }
          }
        ]
      }
    },
    {
      "trace_id": "6cf173d587eb48568a9b2e12dcfbea52",
      "parent_span_id": "438f40bd3b4a41ee",
      "span_id": "f1196292f76e45c0",
      "name": "app.handle",
      "status": "ok",
      "is_remote": false,
      "kind": "server",
      "start_timestamp": 1742921669.178306,
      "end_timestamp": 1742921669.180484,
      "attributes": {
        "sentry.origin": {
          "type": "string",
          "value": "auto"
        }
      }
    }
  ]
}

PropertyTypeRequiredDescription
typestringYesMust be set to "span" to identify this as a span envelope item
item_countintegerYesNumber of span items in the payload
content_typestringYesMust be set to "application/vnd.sentry.items.span.v2+json"

PropertyTypeRequiredDescription
trace_idstringYes32-character hexadecimal string (a valid uuid4 without dashes)
span_idstringYes16-character hexadecimal string (a valid uuid4 without dashes)
parent_span_idstringNo16-character hexadecimal string (a valid uuid4 without dashes)
namestringYesA low cardinality description of what the span represents (e.g., "GET /users", "database.query")
statusstringYesStatus of the span operation. Either "ok" or "error"
is_remotebooleanYesWhether the SpanContext creating the span was received from somewhere else or locally generated
kindstringYesThe kind of span. Values: "server", "client", "producer", "consumer", "internal"
start_timestampnumberYesUnix timestamp (with fractional microseconds) when the span was started
end_timestampnumberYesUnix timestamp (with fractional microseconds) when the span was ended
attributesobjectNoKey-value pairs containing additional metadata about the span
linksarrayNoArray of links connecting this span to other spans or traces

Attributes are stored as key-value pairs where each value is an object with type information:

PropertyTypeRequiredDescription
typestringYesThe data type of the attribute value. Values: "string", "integer", "float", "boolean"
valueanyYesThe actual attribute value, must match the specified type
unitstringNoThe unit of the attribute value. Example values: "ms", "s", "bytes", "count", "percent"

Attribute KeyTypeDescription
sentry.releasestringThe release version of the application
sentry.environmentstringThe environment name (e.g., "production", "staging", "development")
sentry.platformstringThe platform/language (e.g., "php", "javascript", "python")
sentry.sdk.namestringName of the Sentry SDK (e.g., "sentry.php", "sentry.javascript")
sentry.sdk.versionstringVersion of the Sentry SDK

See Sentry Conventions for a full list of supported attributes.

Links connect spans to other spans or traces, enabling distributed tracing:

PropertyTypeRequiredDescription
span_idstringYes16-character hexadecimal string (a valid uuid4 without dashes)
trace_idstringYes32-character hexadecimal string (a valid uuid4 without dashes)
sampledbooleanNoWhether the linked trace was sampled
attributesobjectNoAdditional metadata about the link relationship
Attribute KeyTypeDescription
sentry.link.typestringType of link relationship (e.g., "previous_trace", "child_of", "follows_from")

Timestamps use Unix time with fractional microseconds as a floating-point number:

Copied
1742921669.158209

  • Trace ID: 32-character (128 bits) lowercase hexadecimal string (a valid uuid4 without dashes)
  • Span ID: 16-character (64 bits) lowercase hexadecimal string (a valid uuid4 without dashes)

Example:

Copied
trace_id: "6cf173d587eb48568a9b2e12dcfbea52"
span_id: "438f40bd3b4a41ee"
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").