Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add response.id semantic convention attribute to interactions telemetry.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def _apply_interaction_response_attributes(
telemetry_handler: TelemetryHandler,
) -> None:
invocation.response_model_name = response.model
if getattr(response, "id", None):
invocation.response_id = response.id
Comment thread
DylanRussell marked this conversation as resolved.

usage = response.usage or Usage()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,26 @@ def test_generated_span_has_minimal_genai_attributes(self) -> None:
"generativelanguage.googleapis.com",
)

def test_generated_span_has_response_id(self) -> None:
self.configure_valid_interaction(interaction_id="interaction-123")
self.run_interaction(
model="gemini-2.5-flash",
input="Follow-up question",
)
span = self.otel.get_span_named("interactions.create gemini-2.5-flash")
self.assertEqual(
span.attributes["gen_ai.response.id"], "interaction-123"
)
self.otel.assert_has_event_named(
"gen_ai.client.inference.operation.details"
)
event = self.otel.get_event_named(
"gen_ai.client.inference.operation.details"
)
self.assertEqual(
event.attributes["gen_ai.response.id"], "interaction-123"
)

def test_span_and_event_still_written_when_response_is_exception(
self,
) -> None:
Expand Down