[opentelemetry-instrumentation-google-genai] Add instrumentation for interactions.create and asyncinteractions.create methods#165
Open
DylanRussell wants to merge 16 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-pass OpenTelemetry instrumentation for the Google GenAI SDK Interactions API (interactions.create and aio.interactions.create) within the opentelemetry-instrumentation-google-genai package, alongside a new unit-test suite for input/response parsing and basic span/attribute behavior.
Changes:
- Introduces
src/opentelemetry/instrumentation/google_genai/interactions.pywith sync/async monkey-patching and stream wrappers based onopentelemetry-util-genai. - Adds a new
tests/interactions/suite covering parser behavior, sync/async calls, and basic streaming happy-path behavior. - Updates instrumentation wiring in
instrumentor.py, plus small docs/dev workflow updates and a changelog fragment.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| instrumentation/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/interactions.py | New interactions.create / aio.interactions.create instrumentation + stream wrappers and parsing helpers. |
| instrumentation/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/instrumentor.py | Wires the new interactions instrumentation into the main instrumentor lifecycle. |
| instrumentation/opentelemetry-instrumentation-google-genai/tests/interactions/base.py | Shared test base exercising sync/async interactions spans, attributes, and streaming happy path. |
| instrumentation/opentelemetry-instrumentation-google-genai/tests/interactions/test_interactions_sync.py | Sync interactions test runner implementation. |
| instrumentation/opentelemetry-instrumentation-google-genai/tests/interactions/test_interactions_async.py | Async interactions test runner implementation. |
| instrumentation/opentelemetry-instrumentation-google-genai/tests/interactions/test_parser.py | Unit tests for input/response-to-messages parsing helpers. |
| instrumentation/opentelemetry-instrumentation-google-genai/tests/interactions/util.py | Mock Interaction / SSE event helpers for the interactions tests. |
| instrumentation/opentelemetry-instrumentation-google-genai/tests/interactions/init.py | Test package marker. |
| instrumentation/opentelemetry-instrumentation-google-genai/README.rst | Minor usage text edit (needs update to mention interactions ops). |
| instrumentation/opentelemetry-instrumentation-google-genai/dev/pyproject.toml | Dev environment dependency/source tweaks (currently points to a personal fork). |
| instrumentation/opentelemetry-instrumentation-google-genai/dev/main.env | Dev env comment tweak for interactions API usage. |
| instrumentation/opentelemetry-instrumentation-google-genai/dev/call_instrumentation_lib_and_save_telemetry.py | Dev script edits (currently broken due to missing import). |
| instrumentation/opentelemetry-instrumentation-google-genai/.changelog/151.added | Towncrier fragment for the new interactions instrumentation. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…try-python-genai into interactions_api
lmolkova
approved these changes
Jun 23, 2026
…try-python-genai into interactions_api
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
Initial PR to monkey patch and add instrumentation for the interactions API.
Reference documentation:
Still TODO:
gen_ai.converastion.id)Unlike
generate_contentthere is noGenerateContentConfigwith lots of ways to tune the model, so most of the request attributes that are present ingenerate_contentare missing here..Type of change
How has this been tested?
Unit tests
Checklist