Skip to content

OpenTelemetry tracing#189

Draft
carole-lavillonniere wants to merge 1 commit intomainfrom
otel-tracing
Draft

OpenTelemetry tracing#189
carole-lavillonniere wants to merge 1 commit intomainfrom
otel-tracing

Conversation

@carole-lavillonniere
Copy link
Copy Markdown
Collaborator

@carole-lavillonniere carole-lavillonniere commented Apr 13, 2026

Motivation

Add end-to-end distributed tracing to lstk so developers can inspect the full call tree of any command — Docker API calls, platform API calls, emulator health checks — in a local Jaeger (or any OTLP-compatible) backend.

Closes DRG-410

Changes

  • internal/tracing: new package that initialises the global OTel TracerProvider; exports spans via OTLP/HTTP; silently no-ops when no collector is reachable
  • cmd/root.go: wrapCommandsWithTracing recursively wraps every Cobra RunE with an lstk.<command> root span; sets lstk.exit_code attribute; shuts down the provider with a fresh context on exit to flush buffered spans even after Ctrl+C
  • Docker instrumentation: hooks into the Docker SDK's WithTraceOptions to override the default span name formatter with a docker prefix, avoiding the triple-wrapping that would result from adding a second otelhttp layer
  • Platform API instrumentation: NewPlatformClient wraps its transport with platform prefixed spans
  • AWS emulator instrumentation: aws.NewClient() (no longer takes *http.Client) owns its OTel-wrapped transport with aws prefixed spans
  • Startup health check instrumentation: awaitStartup instruments its polling HTTP client with an emulator-type prefix (e.g. aws GET /_localstack/health), making the readiness polling loop visible in traces
  • Resource attributes: service.name, service.version, os.type, host.arch on all spans
  • LSTK_OTLP_ENDPOINT: new env var (default http://localhost:4318); TLS used automatically for https:// endpoints
  • docker-compose.tracing.yaml: one-command Jaeger setup for local development

Tests

Manually verified with docker compose -f docker-compose.tracing.yaml up -d and lstk start / lstk status. Traces appear in Jaeger at http://localhost:16686 with correct span hierarchy and names. Existing unit and integration tests pass unchanged.

image

@carole-lavillonniere carole-lavillonniere changed the title Add OpenTelemetry distributed tracing Add OpenTelemetry tracing Apr 13, 2026
@carole-lavillonniere carole-lavillonniere changed the title Add OpenTelemetry tracing OpenTelemetry tracing Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant