Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
- Fix overwritten log attributes in vertexai instrumentation
([#3925](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3925))

## Version 2.1b0 (2025-10-16)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,15 @@ def handle_response(
| prediction_service_v1beta1.GenerateContentResponse
| None,
) -> None:
event = LogRecord(
event_name="gen_ai.client.inference.operation.details",
)
attributes = (
get_server_attributes(instance.api_endpoint) # type: ignore[reportUnknownMemberType]
| request_attributes
| get_genai_response_attributes(response)
)
event = LogRecord(
event_name="gen_ai.client.inference.operation.details",
)
event.attributes = attributes.copy()
system_instructions, inputs, outputs = [], [], []
if params.system_instruction:
system_instructions = convert_content_to_message_parts(
Expand Down Expand Up @@ -237,7 +238,6 @@ def handle_response(
for k, v in content_attributes.items()
}
)
event.attributes = attributes
if capture_content in (
ContentCapturingMode.SPAN_AND_EVENT,
ContentCapturingMode.EVENT_ONLY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ def test_tool_events_with_completion_hook(
assert len(logs) == 1
# File upload takes a few seconds sometimes.
time.sleep(3)

# Both log and span have the same reference attributes from upload hook
for key in "gen_ai.input.messages_ref", "gen_ai.output.messages_ref":
assert spans[0].attributes.get(key)
assert logs[0].log_record.attributes.get(key)

assert spans[0].attributes[key] == logs[0].log_record.attributes[key]

assert_fsspec_equal(
spans[0].attributes["gen_ai.output.messages_ref"],
[
Expand Down