Skip to content

feat(google-genai): capture embedding config attributes - #326

Open
tomatotomata wants to merge 4 commits into
open-telemetry:mainfrom
tomatotomata:codex/google-genai-embedding-config-170
Open

feat(google-genai): capture embedding config attributes#326
tomatotomata wants to merge 4 commits into
open-telemetry:mainfrom
tomatotomata:codex/google-genai-embedding-config-170

Conversation

@tomatotomata

@tomatotomata tomatotomata commented Jul 28, 2026

Copy link
Copy Markdown

Summary

  • capture non-sensitive EmbedContentConfig fields on Google GenAI embedding spans
  • support both EmbedContentConfig objects and dict configurations for sync and async calls
  • omit http_options so headers and request settings are not copied into telemetry

Fixes #170

Validation

  • python -m pytest instrumentation/opentelemetry-instrumentation-google-genai/tests/embeddings/test_embeddings.py -q � 6 passed
  • Full package run: 193 passed, 116 skipped; 8 credential-dependent setup errors and 1 async-plugin failure are pre-existing environment limitations
  • Ruff and git diff --check pass

Expose non-sensitive EmbedContentConfig fields under the existing Google GenAI operation config prefix for sync and async embedding calls.

Fixes open-telemetry#170

Assisted-by: Codex
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 28, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-08-05 05:11 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.

pass


def _apply_embedding_request_attributes(

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

You are right: issue #170 explicitly calls for EmbedContentConfig to follow GenerateContentConfig, so treating small config values as safe by default was inconsistent. e258f09 now defaults embedding-config capture off and adds the matching OTEL_GOOGLE_GENAI_EMBED_CONTENT_CONFIG_INCLUDES / ..._EXCLUDES controls. I also added coverage for default omission and explicit opt-in; the focused embedding and instrumentor tests pass (7 tests).

Copilot AI review requested due to automatic review settings July 30, 2026 09:37

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 optional capture of non-sensitive EmbedContentConfig fields as attributes on Google GenAI embedding spans, with opt-in allowlisting via env vars and support for both object and dict configs across sync/async APIs.

Changes:

  • Introduces an embed-content config allowlist (constructor arg + env vars) and threads it into the embeddings instrumentation.
  • Extracts and flattens EmbedContentConfig into gcp.gen_ai.operation.config.* attributes while explicitly excluding http_options.
  • Updates tests/docs/changelog to reflect the new embedding config capture capability.

Reviewed changes

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

Show a summary per file
File Description
instrumentation/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/embeddings.py Captures allowlisted EmbedContentConfig fields (including dict->model conversion) and excludes http_options.
instrumentation/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/instrumentor.py Adds embed-content allowlist initialization and passes it into embeddings instrumentation.
instrumentation/opentelemetry-instrumentation-google-genai/tests/embeddings/test_embeddings.py Adds coverage for default non-capture and allowlisted async capture of embedding config attributes.
instrumentation/opentelemetry-instrumentation-google-genai/README.rst Documents embedding config capture env vars and expands the configuration-recording section.
instrumentation/opentelemetry-instrumentation-google-genai/.changelog/170.added Adds a changelog entry for embedding config attribute capture.
Comments suppressed due to low confidence (1)

instrumentation/opentelemetry-instrumentation-google-genai/README.rst:103

  • README examples/descriptions for config allowlisting are currently misleading: the allowlist matches the fully-qualified attribute keys produced by flatten_dict (e.g. gcp.gen_ai.operation.config.temperature), not bare field names like temperature. Also, embedding invocations set these config attributes on the span (the embedding invocation does not emit a corresponding event).
The instrumentation can optionally record ``GenerateContentConfig`` and
``EmbedContentConfig`` parameters as span and event attributes under the
``gcp.gen_ai.operation.config.*`` namespace.

By default, no config fields are recorded. You can control which fields are
captured using the following environment variables:

* ``OTEL_GOOGLE_GENAI_GENERATE_CONTENT_CONFIG_INCLUDES`` — A comma-separated
  list of config field names to include in the span attributes. For example:

Comment thread instrumentation/opentelemetry-instrumentation-google-genai/.changelog/170.added 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.

Coverage gaps in opentelemetry-instrumentation-google-genai instrumentations

3 participants