llama-stack-mirror/src
Charlie Doern d9f6815d62 feat: remove core.telemetry as a dependency of llama_stack.apis
Remove circular dependency by moving tracing from API protocol definitions
  to router implementation layer.

  Changes:
  - Create apis/common/tracing.py with marker decorator (zero core dependencies)
  - Add @trace_protocol marker decorator to 11 protocol classes
  - Apply actual tracing in core/routers/__init__.py based on protocol marker
  - Move MetricResponseMixin from core to apis (it's an API response type)
  - APIs package is now self-contained with zero core dependencies

  The tracing functionality remains identical - actual trace_protocol from core
  is applied to router implementations at runtime when both telemetry is enabled
  and the protocol has the __trace_protocol__ marker.

  ## Test Plan

  Manual integration test confirms identical behavior to main branch:

  ```bash
  llama stack list-deps --format uv starter | sh
  export OLLAMA_URL=http://localhost:11434
  llama stack run starter

  curl -X POST http://localhost:8321/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{"model": "ollama/gpt-oss:20b",
         "messages": [{"role": "user", "content": "Say hello"}],
         "max_tokens": 10}'

  Verified identical between main and this branch:
  - trace_id present in response
  - metrics array with prompt_tokens, completion_tokens, total_tokens
  - Server logs show trace_protocol applied to all routers

  Existing telemetry integration tests (tests/integration/telemetry/) validate
  trace context propagation and span attributes.

Signed-off-by: Charlie Doern <cdoern@redhat.com>
2025-11-04 14:57:31 -05:00
..
llama_stack feat: remove core.telemetry as a dependency of llama_stack.apis 2025-11-04 14:57:31 -05:00