Skip to content

Add OpenTelemetry distributed tracing across HTTP, DB, and Stellar calls #54

Description

@nanaf6203-bit

Area: Tracing
Priority: P2 — Medium

Description

For debugging request flows across modules (auth → tips → notifications → Stellar Horizon), distributed tracing via OpenTelemetry reveals bottlenecks and dependencies. No tracing exists today.

Acceptance Criteria

  • Install @opentelemetry/api, @opentelemetry/sdk-node, @opentelemetry/auto-instrumentations-node, @opentelemetry/exporter-trace-otlp-http
  • Create src/shared/tracing/tracing.ts that initializes SDK with NodeSDK
  • Auto-instrument: HTTP, Express, NestJS, TypeORM (pg), undici (for Horizon calls)
  • Initialize tracing BEFORE any imports (use --require flag in node command)
  • Use OTLP exporter; endpoint from OTEL_EXPORTER_OTLP_ENDPOINT env var
  • Add traceparent header propagation on outgoing HTTP requests
  • Generate spans for key service methods not covered by auto-instrumentation (e.g. StellarService.verifyPayment)
  • Correlation with logging: include traceId in every structured log line
  • Add unit test verifying telemetry init with mocked exporter

Technical Notes

  • Sampling rate: parentBasedSampler with root sampler configurable
  • Resource attributes: service.name=stellartip-backend, service.version, deployment.environment
  • Document required OTEL_* environment variables in README

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignP2Critical priorityobservability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions