Commit graph

3 commits

Author SHA1 Message Date
Charlie Doern
29f93a6391 refactor: rename trace_protocol marker to mark_as_traced
Rename the marker decorator in apis/common/tracing.py from trace_protocol
to mark_as_traced to disambiguate it from the actual tracing implementation
decorator in core/telemetry/trace_protocol.py.

Changes:
- Rename decorator: trace_protocol -> mark_as_traced
- Rename attribute: __trace_protocol__ -> __marked_for_tracing__
- Update all API protocol files to use new decorator name
- Update router logic to check for new attribute name

This makes it clear that the marker decorator is metadata-only and doesn't
perform actual tracing, while the core decorator does the implementation.

Signed-off-by: Charlie Doern <cdoern@redhat.com>
2025-11-05 16:21:48 -05:00
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
Ashwin Bharambe
471b1b248b
chore(package): migrate to src/ layout (#3920)
Migrates package structure to src/ layout following Python packaging
best practices.

All code moved from `llama_stack/` to `src/llama_stack/`. Public API
unchanged - imports remain `import llama_stack.*`.

Updated build configs, pre-commit hooks, scripts, and GitHub workflows
accordingly. All hooks pass, package builds cleanly.

**Developer note**: Reinstall after pulling: `pip install -e .`
2025-10-27 12:02:21 -07:00
Renamed from llama_stack/apis/conversations/conversations.py (Browse further)