Skip to content

Commit d964ffc

Browse files
nirgaclaude
andauthored
fix(google-generativeai,vertexai): image support for Gemini models (#3340)
Co-authored-by: Claude <[email protected]>
1 parent 85e3c51 commit d964ffc

File tree

11 files changed

+810
-57
lines changed

11 files changed

+810
-57
lines changed

packages/opentelemetry-instrumentation-google-generativeai/opentelemetry/instrumentation/google_generativeai/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
emit_message_events,
1414
)
1515
from opentelemetry.instrumentation.google_generativeai.span_utils import (
16-
set_input_attributes,
16+
set_input_attributes_sync,
1717
set_model_request_attributes,
1818
set_model_response_attributes,
1919
set_response_attributes,
@@ -103,7 +103,7 @@ def _handle_request(span, args, kwargs, llm_model, event_logger):
103103
if should_emit_events() and event_logger:
104104
emit_message_events(args, kwargs, event_logger)
105105
else:
106-
set_input_attributes(span, args, kwargs, llm_model)
106+
set_input_attributes_sync(span, args, kwargs, llm_model)
107107

108108
set_model_request_attributes(span, kwargs, llm_model)
109109

@@ -249,10 +249,12 @@ def _wrap(
249249
class GoogleGenerativeAiInstrumentor(BaseInstrumentor):
250250
"""An instrumentor for Google Generative AI's client library."""
251251

252-
def __init__(self, exception_logger=None, use_legacy_attributes=True):
252+
def __init__(self, exception_logger=None, use_legacy_attributes=True, upload_base64_image=None):
253253
super().__init__()
254254
Config.exception_logger = exception_logger
255255
Config.use_legacy_attributes = use_legacy_attributes
256+
if upload_base64_image:
257+
Config.upload_base64_image = upload_base64_image
256258

257259
def instrumentation_dependencies(self) -> Collection[str]:
258260
return ("google-genai >= 1.0.0",)
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
from typing import Callable
2+
3+
14
class Config:
25
exception_logger = None
36
use_legacy_attributes = True
7+
upload_base64_image: Callable[[str, str, str, str], str] = (
8+
lambda trace_id, span_id, image_name, base64_string: str
9+
)

0 commit comments

Comments
 (0)