ObjectStackObjectStack

Tracing

Tracing protocol schemas

Tracing Protocol - Distributed Tracing & Observability

Comprehensive distributed tracing based on OpenTelemetry standards:

  • Trace context propagation
  • Span creation and management
  • Sampling strategies
  • Integration with tracing backends (Jaeger, Zipkin, etc.)
  • W3C Trace Context standard compliance

Source: packages/spec/src/system/tracing.zod.ts

TypeScript Usage

import { OpenTelemetryCompatibilitySchema, OtelExporterType, SamplingDecision, SamplingStrategyType, SpanSchema, SpanAttributeValueSchema, SpanAttributesSchema, SpanEventSchema, SpanKind, SpanLinkSchema, SpanStatus, TraceContextSchema, TraceContextPropagationSchema, TraceFlagsSchema, TracePropagationFormat, TraceSamplingConfigSchema, TraceStateSchema, TracingConfigSchema } from '@objectstack/spec/system';
import type { OpenTelemetryCompatibility, OtelExporterType, SamplingDecision, SamplingStrategyType, Span, SpanAttributeValue, SpanAttributes, SpanEvent, SpanKind, SpanLink, SpanStatus, TraceContext, TraceContextPropagation, TraceFlags, TracePropagationFormat, TraceSamplingConfig, TraceState, TracingConfig } from '@objectstack/spec/system';

// Validate data
const result = OpenTelemetryCompatibilitySchema.parse(data);

OpenTelemetryCompatibility

OpenTelemetry compatibility configuration

Properties

PropertyTypeRequiredDescription
sdkVersionstringoptionalOTel SDK version
exporter{ type: Enum<'otlp_http' | 'otlp_grpc' | 'jaeger' | 'zipkin' | 'console' | 'datadog' | … +4 more>; endpoint?: string; protocol?: string; headers?: Record<string, string>; … }Exporter configuration
resource{ serviceName: string; serviceVersion?: string; serviceInstanceId?: string; serviceNamespace?: string; … }Resource attributes
instrumentation{ autoInstrumentation: boolean; libraries?: string[]; disabledLibraries?: string[] }optional
semanticConventionsVersionstringoptionalSemantic conventions version

OtelExporterType

OpenTelemetry exporter type

Allowed Values

  • otlp_http
  • otlp_grpc
  • jaeger
  • zipkin
  • console
  • datadog
  • honeycomb
  • lightstep
  • newrelic
  • custom

SamplingDecision

Sampling decision

Allowed Values

  • drop
  • record_only
  • record_and_sample

SamplingStrategyType

Sampling strategy type

Allowed Values

  • always_on
  • always_off
  • trace_id_ratio
  • rate_limiting
  • parent_based
  • probability
  • composite
  • custom

Span

OpenTelemetry span

Properties

PropertyTypeRequiredDescription
context{ traceId: string; spanId: string; traceFlags: integer; traceState?: object; … }Trace context
namestringSpan name
kindEnum<'internal' | 'server' | 'client' | 'producer' | 'consumer'>Span kind
startTimestringSpan start time
endTimestringoptionalSpan end time
durationnumberoptionalDuration in milliseconds
status{ code: Enum<'unset' | 'ok' | 'error'>; message?: string }optional
attributesRecord<string, string | number | boolean | string[] | number[] | boolean[]>Span attributes
events{ name: string; timestamp: string; attributes?: Record<string, string | number | boolean | string[] | number[] | boolean[]> }[]
links{ context: object; attributes?: Record<string, string | number | boolean | string[] | number[] | boolean[]> }[]
resourceRecord<string, string | number | boolean | string[] | number[] | boolean[]>optionalResource attributes
instrumentationLibrary{ name: string; version?: string }optional

SpanAttributeValue

Span attribute value

Union Options

This schema accepts one of the following structures:

Option 1

Type: string


Option 2

Type: number


Option 3

Type: boolean


Option 4

Type: string[]


Option 5

Type: number[]


Option 6

Type: boolean[]



SpanAttributes

Span attributes

Type: Record<string, string | number | boolean | string[] | number[] | boolean[]>


SpanEvent

Span event

Properties

PropertyTypeRequiredDescription
namestringEvent name
timestampstringEvent timestamp
attributesRecord<string, string | number | boolean | string[] | number[] | boolean[]>optionalEvent attributes

SpanKind

Span kind

Allowed Values

  • internal
  • server
  • client
  • producer
  • consumer

Span link

Properties

PropertyTypeRequiredDescription
context{ traceId: string; spanId: string; traceFlags: integer; traceState?: object; … }Linked trace context
attributesRecord<string, string | number | boolean | string[] | number[] | boolean[]>optionalLink attributes

SpanStatus

Span status

Allowed Values

  • unset
  • ok
  • error

TraceContext

Trace context (W3C Trace Context)

Properties

PropertyTypeRequiredDescription
traceIdstringTrace ID (32 hex chars)
spanIdstringSpan ID (16 hex chars)
traceFlagsintegerTrace flags bitmap
traceState{ entries: Record<string, string> }optionalTrace state
parentSpanIdstringoptionalParent span ID (16 hex chars)
sampledboolean
remoteboolean

TraceContextPropagation

Trace context propagation

Properties

PropertyTypeRequiredDescription
formatsEnum<'w3c' | 'b3' | 'b3_multi' | 'jaeger' | 'xray' | 'ottrace' | 'custom'>[]
extractboolean
injectboolean
headers{ traceId?: string; spanId?: string; traceFlags?: string; traceState?: string }optional
baggage{ enabled: boolean; maxSize: integer; allowedKeys?: string[] }optional

TraceFlags

Trace flags bitmap

Type: integer


TracePropagationFormat

Trace propagation format

Allowed Values

  • w3c
  • b3
  • b3_multi
  • jaeger
  • xray
  • ottrace
  • custom

TraceSamplingConfig

Trace sampling configuration

Properties

PropertyTypeRequiredDescription
typeEnum<'always_on' | 'always_off' | 'trace_id_ratio' | 'rate_limiting' | 'parent_based' | 'probability' | 'composite' | 'custom'>Sampling strategy
rationumberoptionalSample ratio (0-1)
rateLimitnumberoptionalTraces per second
parentBased{ whenParentSampled?: Enum<'always_on' | 'always_off' | 'trace_id_ratio' | 'rate_limiting' | 'parent_based' | … +3 more>; whenParentNotSampled?: Enum<'always_on' | 'always_off' | 'trace_id_ratio' | 'rate_limiting' | 'parent_based' | … +3 more>; root?: Enum<'always_on' | 'always_off' | 'trace_id_ratio' | 'rate_limiting' | 'parent_based' | … +3 more>; rootRatio?: number }optional
composite{ strategy: Enum<'always_on' | 'always_off' | 'trace_id_ratio' | 'rate_limiting' | 'parent_based' | … +3 more>; ratio?: number; condition?: Record<string, any> | string | object }[]optional
rules{ name: string; match?: object; decision: Enum<'drop' | 'record_only' | 'record_and_sample'>; rate?: number }[]optional
customSamplerIdstringoptionalCustom sampler identifier

TraceState

Trace state

Properties

PropertyTypeRequiredDescription
entriesRecord<string, string>Trace state entries

TracingConfig

Tracing configuration

Properties

PropertyTypeRequiredDescription
namestringConfiguration name (snake_case, max 64 chars)
labelstringDisplay label
enabledbooleanoptional
sampling{ type: Enum<'always_on' | 'always_off' | 'trace_id_ratio' | 'rate_limiting' | 'parent_based' | … +3 more>; ratio?: number; rateLimit?: number; parentBased?: object; … }optionalTrace sampling configuration
propagation{ formats?: Enum<'w3c' | 'b3' | 'b3_multi' | 'jaeger' | 'xray' | 'ottrace' | 'custom'>[]; extract?: boolean; inject?: boolean; headers?: object; … }optionalTrace context propagation
openTelemetry{ sdkVersion?: string; exporter: object; resource: object; instrumentation?: object; … }optionalOpenTelemetry compatibility configuration
spanLimits{ maxAttributes?: integer; maxEvents?: integer; maxLinks?: integer; maxAttributeValueLength?: integer }optional
traceIdGeneratorEnum<'random' | 'uuid' | 'custom'>optional
customTraceIdGeneratorIdstringoptionalCustom generator identifier
performance{ asyncExport?: boolean; exportInterval?: integer }optional

On this page