[opentelemetry-instrumentation-genai-agno] Add instrumentation for agno model calls - #773
Open
DylanRussell wants to merge 30 commits into
Open
DylanRussell wants to merge 30 commits into
DylanRussell wants to merge 30 commits into
Conversation
Instrument agno.models.base.Model response and streaming methods to emit standard GenAI chat spans with complete request/response attributes, usage metrics, and content capture. Assisted-by: Claude Opus 4.6
Replace Any with concrete Agno Model, Message, MessageData, and ModelResponse types in model patching, stream wrapping, and provider resolution functions. Assisted-by: Claude Opus 4.6
…tent variable Remove redundant capture_content local variables and function parameters, relying directly on invocation.should_capture_content property on InferenceInvocation and RetrievalInvocation. Assisted-by: Claude Opus 4.6
Replace repetitive try/except type conversions with safe_int and safe_float helpers across retrieval, model inference, and streaming wrappers. Assisted-by: Claude Opus 4.6
…hecks Let opentelemetry-util-genai handle None values directly across model response token metrics, embedder tokens, dimension count, and query text. Assisted-by: Claude Opus 4.6
Avoid repeated checks of getattr(model, 'vertexai', False) and GOOGLE_GENAI_USE_VERTEXAI by caching the boolean in is_vertex. Assisted-by: Claude Opus 4.6
Eliminate repetitive is_vertex if/else branching by determining google_provider once at function start. Assisted-by: Claude Opus 4.6
Consolidate duplicate provider resolution logic across resolve_embedder_provider and resolve_model_provider into a single _resolve_provider helper. Assisted-by: Claude Opus 4.6
…_model_output_message Drop unnecessary cast(object, ...) and cast(list[Any], ...) calls and share tool call part extraction via _extract_tool_call_parts. Assisted-by: Claude Opus 4.6
…nput_messages Use list[dict[str, Any]] | None for tool_calls and Iterable[Message] for messages, accessing Message attributes directly. Assisted-by: Claude Opus 4.6
…n embedder functions Use concrete Model | Embedder and Embedder annotations in _resolve_provider, resolve_embedder_provider, and embedder wrappers. Assisted-by: Claude Opus 4.6
…ment) Assisted-by: Claude Opus 4.6
… | ModelResponse Assisted-by: Claude Opus 4.6
Assisted-by: Claude Opus 4.6
opentelemetry-instrumentation-genai-agno] Add instrumentation for agno model calls
DylanRussell
added this pull request to stack #732
September 22, 2026 14:44
Pull request dashboard statusWaiting on reviewers · refreshed 2026-09-23 20:44 UTC Review the latest changes. Status above doesn't look right?
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Model spans start after inference, stream managers are wrapped incorrectly, and required tests are missing.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 2
Open (6)
Wrap outer synchronous model call to capture latency and failures · New Use synchronous stream manager wrapper for context-manager API · New Decode JSON tool-call arguments before storing them · New Add and register chat conformance scenario · New Test synchronous stream early close and single finalization · New Test async stream interruptions, errors, and early close · New
What changed in this PR
Adds Agno model-call telemetry for synchronous, asynchronous, streaming, multimodal, and error paths.
Changes:
- Adds GenAI
chatinstrumentation and stream wrappers. - Adds provider/message/media extraction utilities.
- Adds model tests and documentation.
| File | Description |
|---|---|
patch.py |
Patches model response processing. |
stream.py |
Adds model stream telemetry wrappers. |
utils.py |
Adds model and multimodal extraction. |
test_model.py |
Tests model instrumentation. |
test_embedder.py |
Makes Gemini tests optional. |
README.rst |
Documents model operations. |
.changelog/773.added |
Records the feature. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…sell/more_agno_instrumentation_5
…sell/more_agno_instrumentation_4 # Conflicts: # instrumentation/opentelemetry-instrumentation-genai-agno/README.rst # instrumentation/opentelemetry-instrumentation-genai-agno/src/opentelemetry/instrumentation/genai/agno/utils.py
…sell/more_agno_instrumentation_5 # Conflicts: # instrumentation/opentelemetry-instrumentation-genai-agno/src/opentelemetry/instrumentation/genai/agno/patch.py # instrumentation/opentelemetry-instrumentation-genai-agno/src/opentelemetry/instrumentation/genai/agno/stream.py
…sell/more_agno_instrumentation_5
DylanRussell
force-pushed
the
DylanRussell/more_agno_instrumentation_5
branch
from
September 22, 2026 18:32
24e7603 to
2c94b98
Compare
…sell/more_agno_instrumentation_5 # Conflicts: # instrumentation/opentelemetry-instrumentation-genai-agno/src/opentelemetry/instrumentation/genai/agno/patch.py # instrumentation/opentelemetry-instrumentation-genai-agno/src/opentelemetry/instrumentation/genai/agno/stream.py
…sell/more_agno_instrumentation_5
…rgument for model inference
…sell/more_agno_instrumentation_5 # Conflicts: # instrumentation/opentelemetry-instrumentation-genai-agno/src/opentelemetry/instrumentation/genai/agno/patch.py
…sell/more_agno_instrumentation_5
…sell/more_agno_instrumentation_5 # Conflicts: # instrumentation/opentelemetry-instrumentation-genai-agno/src/opentelemetry/instrumentation/genai/agno/patch.py
…sell/more_agno_instrumentation_5
…sell/more_agno_instrumentation_5
…sell/more_agno_instrumentation_5
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Probably want to wait until #765 lands to avoid duplicate inference calls, but eventually we will want this and that PR will not change the implementation here.
I think once this lands we will have reached parity with the
agnoinstrumentations in open inference and other places..Type of change
How has this been tested?
Unot tests
Checklist