EVENT CONTRACT

Use stable event identities that stay useful at scale.

TrafficWar accepts custom events, but a consistent taxonomy makes maps, metrics, traces, filters, and alerts agree across services.

Required SDK fields

  • event: category. Use http for incoming requests, external for outbound HTTP, or database, redis, or s3 for native calls. Custom categories are accepted.
  • label: stable operation or method and route template, such as GET /users/:id. Share it across related spans. Never include raw IDs or query strings.
  • source: stable emitter, caller origin, or dependency alias, such as backend-a or payment-gateway. Replicas of one route share its label and differ by source. The API key, not source, selects the service.
  • operation_type: specific work such as route.handler, postgres.select, or s3.get_object. It does not select the tier.
  • span_kind: server, client, producer, consumer, or internal. Use server for a handler and client for an outbound dependency.
  • timestamp: actual wall-clock span start, recorded before work. Use RFC 3339 or epoch milliseconds, a Date in Node, or a timezone-aware datetime in Python. The SDK does not substitute capture time.
  • latency_ms: finite, nonnegative inclusive duration in milliseconds from a monotonic clock. Zero is not a placeholder.

HTTP fields and outcome

  • path: optional matched route template, without raw parameters, query strings, or fragments.
  • http_method: required for http. Also send it for external HTTP calls. The SDK trims and uppercases the method; it must be a 1–64-character HTTP token.
  • status_code: actual response status for http or external with a method. If no response exists, omit the status and send a nonblank error or error_code.
  • error: redacted failure message. error_code: stable failure code such as UPSTREAM_TIMEOUT.
  • The server derives is_error from a status of 400 or higher, error, or error_code. It accepts exception as a legacy fallback for an omitted error, but the SDKs do not accept exception in place of an HTTP outcome. Properties do not mark failures. Do not send is_error as an input.

Actors, traces, and custom data

  • distinct_id identifies one stable, pseudonymous application actor across devices without changing the account-level metric grain. Prefer an opaque internal user ID or a backend-derived HMAC; do not send a raw email address.
  • trace_id: one nonblank request ID shared by related spans. Omit for standalone events. An array can contain unrelated spans.
  • event_id: UUID for one event, not a trace. Omit it for an SDK-generated UUIDv7.
  • properties: optional redacted JSON diagnostics or metadata. Keep device identity separate from actor identity.
  • user_agent, ip, country, city: optional caller enrichment, not identities. Omit unless needed and permitted.

SDK validation and the HTTP API

The SDKs require all seven fields above. event, label, source, and operation_type must be nonblank. An invalid event rejects the capture call before enqueue. The direct HTTP API has its own, more permissive wire schema in OpenAPI; use complete events when instrumenting requests.