openinference-instrumentation-google-adk 0.1.5__py3-none-any.whl → 0.1.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -144,7 +144,7 @@ class GoogleADKInstrumentor(BaseInstrumentor): # type: ignore
144
144
 
145
145
  setattr(runners, "tracer", _PassthroughTracer(tracer))
146
146
 
147
- from google.adk.agents.base_agent import (
147
+ from google.adk.agents.base_agent import ( # type: ignore[attr-defined, unused-ignore]
148
148
  tracer, # pyright: ignore[reportPrivateImportUsage]
149
149
  )
150
150
 
@@ -164,7 +164,7 @@ class GoogleADKInstrumentor(BaseInstrumentor): # type: ignore
164
164
 
165
165
  setattr(runners, "tracer", original)
166
166
 
167
- from google.adk.agents.base_agent import (
167
+ from google.adk.agents.base_agent import ( # type: ignore[attr-defined, unused-ignore]
168
168
  tracer, # pyright: ignore[reportPrivateImportUsage]
169
169
  )
170
170
 
@@ -23,7 +23,7 @@ from google.adk.agents.run_config import RunConfig
23
23
  from google.adk.events import Event
24
24
  from google.adk.models.llm_request import LlmRequest
25
25
  from google.adk.models.llm_response import LlmResponse
26
- from google.adk.tools import BaseTool
26
+ from google.adk.tools.base_tool import BaseTool
27
27
  from google.genai import types
28
28
  from opentelemetry import context as context_api
29
29
  from opentelemetry import trace as trace_api
@@ -260,7 +260,8 @@ class _TraceCallLlm(_WithTracer):
260
260
  if system_instruction.parts:
261
261
  for k, v in _get_attributes_from_parts(
262
262
  system_instruction.parts,
263
- prefix=f"{SpanAttributes.LLM_INPUT_MESSAGES}.{input_messages_index}.",
263
+ span_attribute=SpanAttributes.LLM_INPUT_MESSAGES,
264
+ message_index=input_messages_index,
264
265
  text_only=True,
265
266
  ):
266
267
  span.set_attribute(k, v)
@@ -273,7 +274,8 @@ class _TraceCallLlm(_WithTracer):
273
274
  for i, content in enumerate(contents, input_messages_index):
274
275
  for k, v in _get_attributes_from_content(
275
276
  content,
276
- prefix=f"{SpanAttributes.LLM_INPUT_MESSAGES}.{i}.",
277
+ span_attribute=SpanAttributes.LLM_INPUT_MESSAGES,
278
+ message_index=i,
277
279
  ):
278
280
  span.set_attribute(k, v)
279
281
  if llm_response:
@@ -372,7 +374,7 @@ def _get_attributes_from_llm_response(
372
374
  yield from _get_attributes_from_usage_metadata(obj.usage_metadata)
373
375
  if obj.content:
374
376
  yield from _get_attributes_from_content(
375
- obj.content, prefix=f"{SpanAttributes.LLM_OUTPUT_MESSAGES}.0."
377
+ obj.content, span_attribute=SpanAttributes.LLM_OUTPUT_MESSAGES, message_index=0
376
378
  )
377
379
 
378
380
 
@@ -425,12 +427,16 @@ def _get_attributes_from_content(
425
427
  obj: types.Content,
426
428
  /,
427
429
  *,
428
- prefix: str = "",
430
+ span_attribute: str = SpanAttributes.LLM_INPUT_MESSAGES,
431
+ message_index: int = 0,
429
432
  ) -> Iterator[tuple[str, AttributeValue]]:
430
433
  role = obj.role or "user"
434
+ prefix = f"{span_attribute}.{message_index}."
431
435
  yield f"{prefix}{MessageAttributes.MESSAGE_ROLE}", role
432
436
  if parts := obj.parts:
433
- yield from _get_attributes_from_parts(parts, prefix=prefix)
437
+ yield from _get_attributes_from_parts(
438
+ parts, span_attribute=span_attribute, message_index=message_index
439
+ )
434
440
 
435
441
 
436
442
  @stop_on_exception
@@ -438,23 +444,27 @@ def _get_attributes_from_parts(
438
444
  obj: Iterable[types.Part],
439
445
  /,
440
446
  *,
441
- prefix: str = "",
447
+ span_attribute: str = SpanAttributes.LLM_INPUT_MESSAGES,
448
+ message_index: int = 0,
442
449
  text_only: bool = False,
443
450
  ) -> Iterator[tuple[str, AttributeValue]]:
444
451
  for i, part in enumerate(obj):
445
452
  if (text := part.text) is not None:
453
+ prefix = f"{span_attribute}.{message_index}.{MessageAttributes.MESSAGE_CONTENTS}.{i}."
446
454
  yield from _get_attributes_from_text_part(
447
455
  text,
448
- prefix=f"{prefix}{MessageAttributes.MESSAGE_CONTENTS}.{i}.",
456
+ prefix=prefix,
449
457
  )
450
458
  elif text_only:
451
459
  continue
452
460
  elif (function_call := part.function_call) is not None:
461
+ prefix = f"{span_attribute}.{message_index}.{MessageAttributes.MESSAGE_TOOL_CALLS}.{i}."
453
462
  yield from _get_attributes_from_function_call(
454
463
  function_call,
455
- prefix=f"{prefix}{MessageAttributes.MESSAGE_TOOL_CALLS}.{i}.",
464
+ prefix=prefix,
456
465
  )
457
466
  elif (function_response := part.function_response) is not None:
467
+ prefix = f"{span_attribute}.{message_index}."
458
468
  yield f"{prefix}{MessageAttributes.MESSAGE_ROLE}", "tool"
459
469
  if function_response.name:
460
470
  yield f"{prefix}{MessageAttributes.MESSAGE_NAME}", function_response.name
@@ -463,6 +473,7 @@ def _get_attributes_from_parts(
463
473
  f"{prefix}{MessageAttributes.MESSAGE_CONTENT}",
464
474
  safe_json_dumps(function_response.response),
465
475
  )
476
+ message_index += 1
466
477
 
467
478
 
468
479
  @stop_on_exception
@@ -1 +1 @@
1
- __version__ = "0.1.5"
1
+ __version__ = "0.1.7"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openinference-instrumentation-google-adk
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: OpenInference Google ADK Instrumentation
5
5
  Project-URL: Homepage, https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-google-adk
6
6
  Author-email: OpenInference Authors <oss@arize.com>
@@ -16,7 +16,8 @@ Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
- Requires-Python: <3.14,>=3.9
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Requires-Python: <3.15,>=3.9
20
21
  Requires-Dist: openinference-instrumentation>=0.1.32
21
22
  Requires-Dist: openinference-semantic-conventions>=0.1.17
22
23
  Requires-Dist: opentelemetry-api
@@ -0,0 +1,9 @@
1
+ openinference/instrumentation/google_adk/__init__.py,sha256=sCrItt4ilGC3u5hHbjw8papCk_yhUbdur0pzAEg0SIY,7012
2
+ openinference/instrumentation/google_adk/_wrappers.py,sha256=-HOKXlJJZ_xeIloaH22bVeuKd0OQBp51SWJ2glmlV80,20799
3
+ openinference/instrumentation/google_adk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ openinference/instrumentation/google_adk/version.py,sha256=YpKDcdV7CqL8n45u267wKtyloM13FSVbOdrqgNZnSLM,22
5
+ openinference_instrumentation_google_adk-0.1.7.dist-info/METADATA,sha256=Uz6lLP874V1VtNsYa-om4ezi5Jtpf6-jh5DdRc8B8Bc,5245
6
+ openinference_instrumentation_google_adk-0.1.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
7
+ openinference_instrumentation_google_adk-0.1.7.dist-info/entry_points.txt,sha256=SW0GBmqra9efyXhsKjeP6OX4vS7BFpzGeHZgrg_LUzw,211
8
+ openinference_instrumentation_google_adk-0.1.7.dist-info/licenses/LICENSE,sha256=x_Y7OX-lWxSUhmKoivlrD6WN3jWlIHxdug8BJv2SI34,10870
9
+ openinference_instrumentation_google_adk-0.1.7.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,9 +0,0 @@
1
- openinference/instrumentation/google_adk/__init__.py,sha256=HxZ58OnPWAfiCeyEnZom7TmxNKc1kHhuGWkrwFYba2c,6922
2
- openinference/instrumentation/google_adk/_wrappers.py,sha256=h7dP5SvhocUkDfpU3b4JA-FxwOE9WJkkz_qPcdL7MjU,20240
3
- openinference/instrumentation/google_adk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- openinference/instrumentation/google_adk/version.py,sha256=rPSfWgIeq2YWVPyESOAwCBt8vftsTpIkuLAGDEzyRQc,22
5
- openinference_instrumentation_google_adk-0.1.5.dist-info/METADATA,sha256=i7iBJGzw1lW4VUrR4Vm2AMWrnhZRvqje2hBij2WpMhQ,5194
6
- openinference_instrumentation_google_adk-0.1.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- openinference_instrumentation_google_adk-0.1.5.dist-info/entry_points.txt,sha256=SW0GBmqra9efyXhsKjeP6OX4vS7BFpzGeHZgrg_LUzw,211
8
- openinference_instrumentation_google_adk-0.1.5.dist-info/licenses/LICENSE,sha256=x_Y7OX-lWxSUhmKoivlrD6WN3jWlIHxdug8BJv2SI34,10870
9
- openinference_instrumentation_google_adk-0.1.5.dist-info/RECORD,,