Skip to content

feat: OpenTelemetry distributed tracing across API and worker #154

Description

@dotunv

Overview

Add request-level tracing using OpenTelemetry that propagates trace context across the API, worker, and Stellar Horizon calls for end-to-end visibility.

Motivation

When a transfer fails mid-settlement, there is no way to trace the full lifecycle of that request across the API handler, queue dispatch, worker processing, and Horizon submission. Distributed tracing enables operators to pinpoint exactly where failures occur.

Proposed Design

  1. Instrument the HTTP server with OpenTelemetry for automatic span creation
  2. Propagate trace context into Asynq job metadata so worker jobs inherit parent traces
  3. Instrument Horizon client calls to create child spans
  4. Export traces to configurable OTEL_EXPORTER_ENDPOINT (supports Jaeger, Grafana Tempo, etc.)
  5. Add trace_id to all log entries for correlation
  6. Make tracing opt-in via OTEL_ENABLED=true env var (disabled by default)

Acceptance Criteria

  • HTTP requests create traces with unique trace IDs
  • Worker jobs inherit trace context from the dispatching API request
  • Horizon client calls appear as child spans within the request trace
  • Traces are exported to configured OTEL endpoint
  • Trace IDs appear in structured log entries
  • Tracing is disabled by default (no overhead when OTEL_ENABLED is not set)
  • No performance impact when tracing is disabled
  • Tests verify span creation and context propagation

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programbackendBackend / API workenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions