Skip to content

[opentelemetry-instrumentation-genai-agno] Add instrumentation for agno embedding methods - #738

Open
DylanRussell wants to merge 1 commit into
DylanRussell/more_agno_instrumentation_3from
DylanRussell/more_agno_instrumentation_4
Open

DylanRussell wants to merge 1 commit into
DylanRussell/more_agno_instrumentation_3from
DylanRussell/more_agno_instrumentation_4

Conversation

@DylanRussell

@DylanRussell DylanRussell commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Monkey patch the built in get_embedding methods. Use a ContextVar (_SUPPRESS_EMBEDDING) to avoid double instrumenting in cases where one monkey patched embedding method delegates to another which can happen.

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

Unit tests

Checklist

  • Followed the style guidelines of this project
  • Changelog updated if the change requires an entry
  • Unit tests added
  • Documentation updated

Copilot AI lite review requested due to automatic review settings September 17, 2026 16:19
@DylanRussell
DylanRussell requested a review from a team as a code owner September 17, 2026 16:19
@DylanRussell
DylanRussell changed the base branch from main to DylanRussell/more_agno_instrumentation_3 September 17, 2026 16:20
@DylanRussell
DylanRussell force-pushed the DylanRussell/more_agno_instrumentation_4 branch from 1068df3 to fe4237c Compare September 17, 2026 16:21
@DylanRussell
DylanRussell added this pull request to stack #732 September 17, 2026 16:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Adds OpenTelemetry tracing for Agno embedding operations, including built-in and user-defined embedder classes.

Changes:

  • Wraps synchronous and asynchronous embedding methods and records model, provider, dimensions, usage, and errors.
  • Adds nested-call suppression and support for custom embedder subclasses created at runtime.
  • Adds unit tests, README documentation, and a changelog entry.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
instrumentation/opentelemetry-instrumentation-genai-agno/tests/test_embedder.py Adds coverage for sync, async, nested, usage, error, and uninstrumentation behavior.
instrumentation/opentelemetry-instrumentation-genai-agno/src/opentelemetry/instrumentation/genai/agno/patch.py Adds embedder discovery, monkey-patching, tracing wrappers, and telemetry extraction.
instrumentation/opentelemetry-instrumentation-genai-agno/README.rst Documents the newly instrumented embedder methods.
instrumentation/opentelemetry-instrumentation-genai-agno/.changelog/738.added Records the new embedder instrumentation feature.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-10-17 01:44 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@DylanRussell
DylanRussell force-pushed the DylanRussell/more_agno_instrumentation_4 branch from e72d878 to 7c0f49d Compare September 17, 2026 18:28
_ACTIVE_FOREGROUND_WORKFLOWS: contextvars.ContextVar[frozenset[int]] = (
contextvars.ContextVar("_ACTIVE_FOREGROUND_WORKFLOWS", default=frozenset())
)
_SUPPRESS_EMBEDDING: contextvars.ContextVar[bool] = contextvars.ContextVar(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's wait for #663 to land for embeddings before we do this, similarly to #683 for inference. Otherwise, we risk emitting duplicate embedding spans when underlying client instrumentation is also present.

@DylanRussell DylanRussell Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point that we have the duplicate embedding issue here too.. but this was added to resolve the issue that the embedding methods within agno itself can call eachother.. (ex get_embedding can call get_embedding_and_usage)... in this case i think it makes sense to disable the monkey patching altogether from the nested call when we detect it.. WDYT ?

@DylanRussell
DylanRussell force-pushed the DylanRussell/more_agno_instrumentation_4 branch 2 times, most recently from 3a1a6f5 to c503008 Compare October 14, 2026 15:01
@DylanRussell
DylanRussell force-pushed the DylanRussell/more_agno_instrumentation_4 branch from c503008 to 81e4b3a Compare October 16, 2026 20:28

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants