open-telemetry / open-telemetry/opentelemetry-python-genai

[util-genai] Investigate streaming helpers for agent and workflow invocations

Open
#595 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
39
Forks
63
Avg merge
1d 15h
Merged PRs (30d)
175

Description

SyncStreamWrapper and AsyncStreamWrapper in opentelemetry-util-genai are designed around LLM inference invocations (chat, generate_content). When passed an invocation, they mark it as streamed and record client token streaming metrics (gen_ai.client.operation.time_to_first_chunk and time_per_output_chunk) on each chunk.

Agent (invoke_agent) and workflow (invoke_workflow) operations do not define these client token metrics under GenAI semantic conventions. As a result, agent instrumentations either avoid passing the invocation to super().__init__ (e.g. qwen-agent) to manage the lifecycle manually, or pass it and emit invalid metrics (e.g. agno).

Agent instrumentations also duplicate logic for accumulating stream chunks into output_messages based on content capture settings, and serializing structured content (Pydantic models, dataclasses) into JSON strings.

Investigate possible approaches in util-genai to:

  • Support streaming agent and workflow invocations without recording client token timing metrics.
  • Reduce boilerplate across agent instrumentations for chunk content accumulation and structured object serialization.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading SyncStreamWrapper and AsyncStreamWrapper in opentelemetry-util-genai, then compare the qwen-agent and agno instrumentation approaches described in the issue. Investigate how agent and workflow invocations can avoid unsupported client token metrics while sharing chunk accumulation and structured-object serialization. Done means a clear, project-consistent approach is identified and its expected behavior is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability-sre
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.