Skip to content

[T-126] [Optional] OpenTelemetry tracing (API → orchestrator → worker) behind observability.tracing.enabled #215

Closed
Reet24-del/RoboProbe
#1

Description

@CodewithJha

Task T-126 · Milestone M10 — Evaluation · Size S · Priority P3 · Epic #10

Implements NFR-OBS-001

Branch feat/t-126-optional-opentelemetry-tracing-api-orchestrator — one task = one branch = one PR (doc 32 §6)

Summary

Add optional OTel instrumentation (FastAPI, SQLAlchemy, custom spans for run lifecycle) exporting OTLP to a collector in the observability profile; disabled by default with zero overhead.

Context / motivation

Doc 21 §5.3 (optional tracing).

Scope

In scope

  • Trace id propagated into problem+json trace_id and logs.

Implementation guidance

  • roboprobe/observability/tracing.py: def configure_tracing(settings: ObservabilitySettings, service_name: str) -> None — a no-op unless observability.otlp_endpoint is set (doc 27 §4.10, doc 21 §5.3); imports opentelemetry lazily inside the function (extra roboprobe[otel]).
  • Instrument FastAPI and SQLAlchemy, plus manual spans campaign.tick, strategy.propose, run.execute with children materialize, episode, judge, persist (doc 21 §5.3).
  • Propagate trace_id into the structlog context and problem+json trace_id.
  • Optionally add an OTel collector + Jaeger to the observability profile.
  • Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff PLR2004); public APIs typed (mypy strict) and documented.

Configuration keys

From the configuration reference (doc 27). Keys marked (new) must be added to the typed settings models and appear in the generated reference (T-003c).

  • observability.otlp_endpoint
  • observability.service_name

Acceptance criteria

  • Disabled: no OTel import at runtime (test).
  • Enabled: spans visible in collector.
  • With the endpoint unset, opentelemetry is not imported (sys.modules test).
  • Span names exactly as in doc 21 §5.3.
  • Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
  • Docs, config reference and CHANGELOG Unreleased updated where behaviour, keys or interfaces changed.
  • Definition of Done (doc 32 §3) satisfied.

Tests required

  • tests/integration/test_tracing.py.

Dependencies

Blocked by: #214 (T-125)

Blocks: no other task (leaf)

Parallelization notes

Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:

  • backend/src/roboprobe/observability/tracing.py

Optional.

Definition of Done

Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-126 (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.

References

Design docs: doc 21 §5.3

Requirements: NFR-OBS-001 (traceability: doc 28)

External:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions