Skip to content

[opentelemetry-instrumentation-google-genai] Add instrumentation for interactions.create and asyncinteractions.create methods#165

Open
DylanRussell wants to merge 16 commits into
open-telemetry:mainfrom
DylanRussell:interactions_api
Open

[opentelemetry-instrumentation-google-genai] Add instrumentation for interactions.create and asyncinteractions.create methods#165
DylanRussell wants to merge 16 commits into
open-telemetry:mainfrom
DylanRussell:interactions_api

Conversation

@DylanRussell

Copy link
Copy Markdown
Contributor

Description

Initial PR to monkey patch and add instrumentation for the interactions API.

Reference documentation:

Still TODO:

  • Add tool definitions.
  • Add interaction id somewhere (probably gen_ai.converastion.id)
  • Expand input / output messages to capture all inputs / outputs -- the SDK accepts many different types here.

Unlike generate_content there is no GenerateContentConfig with lots of ways to tune the model, so most of the request attributes that are present in generate_content are missing here..

Type of change

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

How has this been tested?

Unit tests

Checklist

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

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.

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.py with sync/async monkey-patching and stream wrappers based on opentelemetry-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.

Comment thread instrumentation/opentelemetry-instrumentation-google-genai/README.rst Outdated
Comment thread instrumentation/opentelemetry-instrumentation-google-genai/dev/pyproject.toml Outdated
DylanRussell and others added 4 commits June 23, 2026 17:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread instrumentation/opentelemetry-instrumentation-google-genai/dev/pyproject.toml Outdated
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