[opentelemetry-instrumentation-genai-agno] Add instrumentation for Agno Team, Workflow, and Model response methods. - #350
Conversation
There was a problem hiding this comment.
Pull request overview
Adds additional Agno instrumentation coverage by patching Team, Workflow, Step, and Model response methods to emit GenAI spans via opentelemetry-util-genai, and updates package docs/tests accordingly.
Changes:
- Extend patching to
Team.run/arun,Workflow.run/arun,Step.execute/aexecute, andModel.response/aresponse. - Add unit tests covering Team + Model response instrumentation and basic Workflow/Step coverage.
- Document supported operations in
README.rstand add a changelog fragment.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| instrumentation/opentelemetry-instrumentation-genai-agno/src/opentelemetry/instrumentation/genai/agno/patch.py | Adds wrappers for Team/Workflow/Step/Model methods and model message extraction for inference spans. |
| instrumentation/opentelemetry-instrumentation-genai-agno/tests/test_agent.py | Adds tests for Team + Model response spans and basic Workflow/Step span assertions. |
| instrumentation/opentelemetry-instrumentation-genai-agno/README.rst | Documents newly supported operations. |
| instrumentation/opentelemetry-instrumentation-genai-agno/.changelog/350.added | Changelog entry for the added instrumentation coverage. |
Suppressed comments (2)
instrumentation/opentelemetry-instrumentation-genai-agno/src/opentelemetry/instrumentation/genai/agno/patch.py:108
- This PR instruments
Step.aexecute, but there is no corresponding async test coverage validating that span emission works for the async variant.
wrap_function_wrapper(
_AGNO_STEP_MODULE,
f"{_STEP_CLASS}.aexecute",
_step_aexecute(handler),
)
instrumentation/opentelemetry-instrumentation-genai-agno/tests/test_agent.py:309
- Skipping only on
fastapibeing absent may not cover other optional dependency/import failures inagno.workflow.step. It’s more robust to skip on importing the step module itself.
pytest.importorskip("fastapi")
from agno.workflow.step import Step # noqa: PLC0415
Pull request dashboard statusWaiting on the author · refreshed 2026-08-07 00:00 UTC Respond to 4 review items (e.g. link a commit, explain why not, ask a follow-up): Status above doesn't look right?
|
opentelemetry-instrumentation-genai-agno] Add instrumentation for Agno Team, Workflow, Step, and Model response methods.opentelemetry-instrumentation-genai-agno] Add instrumentation for Agno Team, Workflow, and Model response methods.
lmolkova
left a comment
There was a problem hiding this comment.
LGTM, but the metric should be gen_ai.invoke_workflow.duration
# Conflicts: # instrumentation/opentelemetry-instrumentation-genai-agno/src/opentelemetry/instrumentation/genai/agno/patch.py
…guard conversation_id assignment
…low.duration and make upstream semconv filter optional
| return invocation | ||
|
|
||
|
|
||
| def _start_model_invocation( |
There was a problem hiding this comment.
do we need to report inference from agno? does it rely on openai / anthropic / google genai to make model calls? if so, why not rely on the corresponding instrumentations to do it?
Otherwise we end up with duplication if inference is recorded by both layers.
| ) == self.advice_id and self.message_substring in str( | ||
| violation.get("message", "") | ||
| ) | ||
| ) == self.advice_id and self.message_substring in str(violation) |
There was a problem hiding this comment.
do we need to relax? I'd rather make it more strict
| raise RuntimeError( | ||
| f"genai repo's versions.env is missing {missing!s}" | ||
| ) from missing | ||
| upstream_version = upstream_pins.get("SEMCONV_VERSION") |
Description
Add instrumentation for the following methods:
I'm not certain if it makes sense to model
teamsfunction call as ainvoke agentspan or if we might want to add a new sem conv span name for it.. But that is how both open inference and alibaba longsuite modeled it and it sort of makes sense. https://docs.agno.com/teams/overview#when-to-use-teams and https://docs.agno.com/workflows/overview#when-to-use-workflows describe the differences between workflows / agents / teams..Next steps:
Add run_stream / arun_stream / response_stream / aresponse_stream using SyncStreamWrapper and AsyncStreamWrapper.
Add Parallel.execute and Parallel.aexecute wrapping for workflow parallel steps.
Enrich InputMessage / OutputMessage extraction to include tool calls, tool responses, and multimodal parts (for Model calls)
Instrument
Step(awaiting on open-telemetry/semantic-conventions-genai#188)Type of change
How has this been tested?
Unit tests
Checklist