open-telemetry / open-telemetry/opentelemetry-python-contrib
Tool calls and responses not recorded in message events in opentelemetry-instrumentation-google-genai
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
AFAICT this is not addressed by https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3446, which adds spans to the tool calls themselves. The events as described in https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-events/ are missing gen_ai.tool.message and the tool_calls part of the gen_ai.assistant.message event body.
For example, in https://github.com/pydantic/logfire/blob/94e0a605b6c65342650fd2c8bd5f587c3c3399d8/tests/otel_integrations/test_google_genai.py I have:
from google.genai import Client, types
client = Client()
def get_current_weather(location: str) -> str:
"""Returns the current weather.
Args:
location: The city and state, e.g. San Francisco, CA
"""
return 'rainy'
response = client.models.generate_content( # type: ignore
model='gemini-2.0-flash-001',
contents='What is the weather like in Boston?',
config=types.GenerateContentConfig(
tools=[get_current_weather],
),
)
and it just produces events data like this:
{'content': 'What is the weather like in Boston?', 'role': 'user'},
{
'index': 0,
'finish_reason': 'STOP',
'message': {'role': 'assistant', 'content': ['It is rainy in Boston, MA.\n']},
},
It's calling the tools, but not showing it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Google GenAI example in tests/otel_integrations/test_google_genai.py and compare its emitted events with the GenAI events specification. Trace the google-genai instrumentation's message-event handling, then verify that tool calls produce gen_ai.tool.message and that assistant events include tool_calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100