Skip to main content

@siglo/opentelemetry Adapter Guide

@siglo/opentelemetry provides vendor-neutral distributed tracing, semantic spans, context event streaming, and W3C Trace Context propagation for Siglo workflows. It is fully compliant with the OpenTelemetry API (@opentelemetry/api v1.9.0+) and integrates seamlessly with collectors like Jaeger, Zipkin, Datadog, Prometheus, New Relic, and AWS X-Ray.

1. Overview & Architecture

The OpenTelemetry integration creates an end-to-end distributed span hierarchy covering workflows, steps, retries, and context mutations:

2. Installation & Requirements

Install @siglo/opentelemetry and the OpenTelemetry API:
Recommended OpenTelemetry SDK packages for Node.js:

3. Semantic Attributes Reference

SemanticAttributes defines standardized OpenTelemetry attribute keys:

4. API Reference

instrumentWorkflow(workflow, options)

Instruments a Flow instance with a root span, sets execution attributes, and automatically instruments all child steps:

Options (SigloTelemetryOptions):

  • tracer (Tracer): Custom OpenTelemetry Tracer instance. If omitted, uses trace.getTracer('@siglo/opentelemetry', '1.2.0').
  • serviceName (string): Tracer service name identifier.
  • workflowName (string): Override workflow span label.
  • workflowVersion (string): Workflow version (default: '1.0.0').
  • allowNamespace (boolean): If true, injects siglo.namespace into span attributes. Default false to prevent accidental namespace leakage.
  • allowContextFields (string[]): Whitelist of step context mutation keys that are allowed to be recorded as span attributes.
  • redactHook ((key: string, value: unknown) => unknown): Sanitizer hook to scrub sensitive or PII data before recording attributes.

instrumentStep(step, options)

Wraps an individual Step with a child span covering step execution, attempt count tracking, status reporting, and exception capturing:

createTelemetryStorageAdapter(options)

Creates a StorageAdapter that transforms context changes into OpenTelemetry span attributes:

Security & PII Protection:

By default, no context fields are streamed to OpenTelemetry spans. Only fields explicitly declared in allowContextFields are emitted as siglo.context.<field>, and all values pass through redactHook if configured.

W3C Distributed Context Propagation Helpers

  • injectTraceContext(carrier, ctx?): Injects active OpenTelemetry span context into headers or metadata dictionaries.
  • extractTraceContext(carrier, ctx?): Extracts OpenTelemetry Context from HTTP headers or Kafka message headers.
  • getTraceHeaders(span?): Returns { traceparent: string, tracestate?: string } from the active or supplied span.

5. Complete Production Instrumentation Example