Skip to content

feat(tracing): add OpenTelemetry distributed tracing for multi-agent calls (#305) - #330

Merged
vybe merged 5 commits into
mainfrom
feature/305-otel-tracing
Apr 14, 2026
Merged

vybe merged 5 commits into
mainfrom
feature/305-otel-tracing

Conversation

@vybe

@vybe vybe commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add OTel auto-instrumentation for FastAPI, httpx, and Redis
  • Initialize SDK with configurable sampling (default 10%, via OTEL_SAMPLE_RATE)
  • Inject trace_id and span_id into structured JSON logs for log-trace correlation
  • Export traces to existing OTel Collector (trinity-otel-collector:4317)

Traces propagate through inter-agent calls via traceparent header, enabling end-to-end request tracing across Agent A → Backend → Agent B.

Changes

  • docker/backend/Dockerfile — 6 new OTel packages
  • src/backend/main.py — OTel SDK initialization (~40 lines)
  • src/backend/logging_config.py — trace_id in JSON log entries
  • docs/memory/architecture.md — document new tracing capability

Test Plan

  • Backend starts with OTEL_ENABLED=1
  • OTel Collector receives traces (confirmed via debug exporter)
  • trace_id appears in JSON log entries during request handling
  • Syntax validation passes
  • Manual: verify trace propagation through agent-to-agent call

Configuration

OTEL_ENABLED=1                    # Enable tracing (default: 0)
OTEL_SAMPLE_RATE=0.1              # Sample 10% of requests (default)
OTEL_COLLECTOR_ENDPOINT=http://trinity-otel-collector:4317

Closes #305

🤖 Generated with Claude Code

vybe and others added 5 commits April 14, 2026 13:21
…calls (#305)

- Add OTel auto-instrumentation packages (fastapi, httpx, redis)
- Initialize OTel SDK with configurable sampling (OTEL_SAMPLE_RATE, default 10%)
- Inject trace_id and span_id into structured JSON logs
- Export traces to existing OTel Collector (trinity-otel-collector:4317)
- Enable via OTEL_ENABLED=1 environment variable

Traces propagate through inter-agent calls via traceparent header,
enabling end-to-end request tracing across Agent A → Backend → Agent B.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add tests/unit/test_otel_trace_logging.py with 3 tests:
  - test_log_includes_trace_id_when_span_active
  - test_log_excludes_trace_id_when_no_span
  - test_log_preserves_standard_fields
- Add opentelemetry-api and opentelemetry-sdk to test requirements
- Update test-runner.md catalog with new test file

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@vybe
vybe merged commit 9146d79 into main Apr 14, 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.

feat: OpenTelemetry distributed tracing for multi-agent request flows (RELIABILITY-002)

1 participant