Skip to content

refactor: move tracing onto plugin/hook pattern #1045

Closed

Description

@ajbozarth

Background

Tracing is the only telemetry pillar still using pre-plugin instrumentation. Metrics (#443) and logging (#442) both migrated to the canonical plugin/hook pattern during their epics; tracing needs the same treatment to unblock the rest of epic #444.

Current state

  • mellea/telemetry/backend_instrumentation.py exposes instrument_generate_from_context, instrument_generate_from_raw, start_generate_span, record_token_usage, record_response_metadata.
  • Each of 5 backends (openai, ollama, huggingface, litellm, watsonx) calls these helpers inline (~20 call sites total).
  • The active span is stored in mot._meta["_telemetry_span"] so it can survive the asyncio.create_task boundary and be closed in post_processing() / error path.
  • Tracing reads raw provider responses for attribute extraction instead of mot.generation.

Scope

Phase & dependencies

Phase 1 (foundation). No internal deps. Blocks all of Phase 2 and Phase 3. Sequencing within Phase 1: this issue → #1046 → #1047; all three likely land as a single PR per the epic plan.

Coordination notes

Acceptance criteria

Parent epic: #444

Activity

  1. self-assigned this
    on May 8, 2026
  2. added
    area/telemetry
    on May 19, 2026
  3. added
    area/backends
    on May 20, 2026
  4. added a commit that references this issue on Jun 1, 2026
    0a22d47
  5. added a commit that references this issue on Jun 10, 2026
    bbddd0e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/backendsarea/telemetryrefactor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions