TRACE EVENTS

Connect spans with one trace ID and route label.

A trace is a group of ordinary TrafficWar events. Share one trace_id and label across the request and describe each tier with its normal event fields.

Example multi-tier trace

This fixture shows field values and wire order. In your integration, use observed timestamps, durations, and outcomes.

TypeScript
const trace_id = crypto.randomUUID();
const distinct_id = "usr_7f3a91c2";
const label = "POST /checkout";
const started_at = Date.now();
const at = (offset_ms: number) => new Date(started_at + offset_ms);

trafficwar.capture([
  { event: "database", label, trace_id, distinct_id, source: "db-primary",
    operation_type: "postgres.select", span_kind: "client",
    timestamp: at(20), latency_ms: 12.4 },
  { event: "external", label, trace_id, distinct_id, source: "payment-gateway",
    operation_type: "payment.authorize", span_kind: "client",
    timestamp: at(34), latency_ms: 13.0, http_method: "POST", status_code: 200 },
  { event: "s3", label, trace_id, distinct_id, source: "receipts.ovh-s3",
    operation_type: "s3.put_object", span_kind: "client",
    timestamp: at(50), latency_ms: 18.3 },
  { event: "http", label, trace_id, distinct_id, source: "checkout-api",
    operation_type: "route.handler", span_kind: "server",
    timestamp: at(8), latency_ms: 96.1, http_method: "POST", status_code: 200 },
  { event: "http", label, trace_id, distinct_id, source: "web", http_method: "POST",
    operation_type: "http.request", span_kind: "client", latency_ms: 184.2,
    timestamp: at(0), status_code: 200 },
]);

Send only measured spans

Send related spans contiguously in dependency → backend → edge order, with a shared trace_id and label but distinct event IDs. An array is not itself a trace. There are no span_id or parent_span_id fields.

Keep measured child intervals inside the parent interval. Overlapping dependency calls can sum to more than their parent; do not adjust real measurements. A server-side interval is not a browser round trip. If all you measured was the handler, send one complete server span.

How SpaceWar selects a tier

database, redis, s3, and external go to Infrastructure. For HTTP, the source is checked before span_kind: an HTTP(S) URL or a web/browser/client/edge/frontend prefix selects Edge; an api/backend/server token selects Backend. If no source rule matches, server selects Backend and client selects Edge; other roles fall back to Edge.

Use a plain alias such as backend-a for handlers. For measured edge spans, use an allowlisted origin or a bounded alias such as web-direct or web-other. Do not use the API Host header as a caller origin. Edge and Backend stations group by label; source distinguishes instances. External stations group by source; operation_type names the call, not its tier.

S3 source convention

For S3, source is a provider alias such as ovh-s3, aws-s3, or minio. Use bucket.provider, such as receipts.ovh-s3, only when separate bucket stations are useful. The operation_type remains the operation dot.