perf: TracerProvider setup with MockTracer/MockSpan no-ops #204

Closed
opened 2026-03-24 23:50:06 +00:00 by kert · 2 comments
Owner

Implement src/perf/_tracer.py following marimo _tracer.py pattern.

Tasks

  • MockSpan with no-op set_attribute(), set_status(), __enter__/__exit__
  • MockTracer with no-op start_as_current_span()
  • create_tracer(name) — returns real OTel tracer when STACK_TELEMETRY=true, MockTracer otherwise
  • Lazy OTel imports — opentelemetry only imported when telemetry is enabled
  • Two named tracers: pipeline_tracer = create_tracer("stack.pipeline"), api_tracer = create_tracer("stack.api")
  • _enabled() reads STACK_TELEMETRY env var and stack.toml [telemetry].enabled
  • Tests: verify MockTracer when disabled, real tracer when enabled
Implement `src/perf/_tracer.py` following marimo `_tracer.py` pattern. ## Tasks - [ ] `MockSpan` with no-op `set_attribute()`, `set_status()`, `__enter__`/`__exit__` - [ ] `MockTracer` with no-op `start_as_current_span()` - [ ] `create_tracer(name)` — returns real OTel tracer when `STACK_TELEMETRY=true`, MockTracer otherwise - [ ] Lazy OTel imports — `opentelemetry` only imported when telemetry is enabled - [ ] Two named tracers: `pipeline_tracer = create_tracer("stack.pipeline")`, `api_tracer = create_tracer("stack.api")` - [ ] `_enabled()` reads `STACK_TELEMETRY` env var and `stack.toml [telemetry].enabled` - [ ] Tests: verify MockTracer when disabled, real tracer when enabled
kert added this to the P26: Pipeline Telemetry — OTel instrumentation, perf module, Grafana dashboards milestone 2026-03-24 23:50:06 +00:00
Author
Owner

Starting work. Core MockTracer/MockSpan and TracerProvider setup already exist from #203. Remaining:

  • Tests with real OTel provider (STACK_TELEMETRY=true)
  • Verify span creation, attribute recording, context propagation
  • Verify OTLP fallback to FileExporter when collector unreachable
Starting work. Core MockTracer/MockSpan and TracerProvider setup already exist from #203. Remaining: - Tests with real OTel provider (STACK_TELEMETRY=true) - Verify span creation, attribute recording, context propagation - Verify OTLP fallback to FileExporter when collector unreachable
Author
Owner

Complete. _tracer.py with MockTracer/MockSpan + TracerProvider was built in #203. Added 9 deep tests in test_tracer.py:

  • Real span creation with attributes
  • Nested parent→child→grandchild span hierarchy
  • Exception recording on spans
  • Status code propagation
  • Timing (end > start)
  • create_tracer mock vs real dispatch
  • Endpoint resolution (env override, config fallback)

✅ 9/9 passed, lint clean.

Complete. `_tracer.py` with MockTracer/MockSpan + TracerProvider was built in #203. Added 9 deep tests in `test_tracer.py`: - Real span creation with attributes - Nested parent→child→grandchild span hierarchy - Exception recording on spans - Status code propagation - Timing (end > start) - create_tracer mock vs real dispatch - Endpoint resolution (env override, config fallback) ✅ 9/9 passed, lint clean.
kert closed this issue 2026-03-25 00:04:23 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: homelab/stack#204