Skip to content

feat(observability): add Loki logging and OpenTelemetry tracing#5

Merged
pkarpovich merged 17 commits into
masterfrom
add-loki-and-tracing
Mar 22, 2026
Merged

feat(observability): add Loki logging and OpenTelemetry tracing#5
pkarpovich merged 17 commits into
masterfrom
add-loki-and-tracing

Conversation

@pkarpovich

Copy link
Copy Markdown
Owner

Summary

  • Add observability package with structured slog logging to Grafana Loki (batched, level-labeled, trace_id correlated) and OpenTelemetry tracing via OTLP HTTP exporter
  • Full migration of all 81 log.Printf calls across 12 files to structured slog with proper log levels and key-value attributes
  • Add tracing spans to HTTP handlers, tracker providers, and download task operations with context propagation

Test plan

  • go test ./... — all tests pass (including new observability, tracing, and config tests)
  • Deploy with LOKI_URL set → verify logs appear in Grafana Loki with service/level labels
  • Deploy with OTEL_EXPORTER_OTLP_ENDPOINT set → verify traces appear in Tempo/Jaeger
  • Verify trace_id appears in Loki log entries when tracing is enabled
  • Deploy without observability env vars → verify app works as before (stdout logging, noop tracing)

🤖 Generated with Claude Code

pkarpovich and others added 17 commits March 22, 2026 22:02
…OpenTelemetry tracing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…g in main.go

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use fresh context with timeout for tracing shutdown instead of
  potentially cancelled parent context
- Use slog.*Context variants in HTTP handlers to enable trace_id
  correlation in Loki logs
- Remove noisy warning from RutrackerProvider.getLastComment that
  fired on every parse
- Update CLAUDE.md with observability package docs and new config vars

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Match turtle-hub convention so observability works out of the box
on the shared proxy network without explicit env var configuration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pkarpovich pkarpovich merged commit ab17f7a into master Mar 22, 2026
3 checks passed
@pkarpovich pkarpovich deleted the add-loki-and-tracing branch March 22, 2026 22:58
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