Skip to content

Commit 33dad48

Browse files
authored
feat(google_genai): trace interactions api methods (#210)
Instrument the Google GenAI Interactions API for sync and async create, get, cancel, delete, and streaming calls. The new tracing normalizes interaction inputs and outputs, records usage and timing, tracks previous_interaction_id, and emits nested tool spans for interaction tool calls.
1 parent fef79f6 commit 33dad48

11 files changed

Lines changed: 2045 additions & 29 deletions
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
interactions:
2+
- request:
3+
body: '{"input":"What is the capital of Italy?","model":"gemini-2.5-flash"}'
4+
headers:
5+
Accept:
6+
- application/json
7+
Accept-Encoding:
8+
- gzip, deflate, zstd
9+
Connection:
10+
- keep-alive
11+
Content-Length:
12+
- '68'
13+
Content-Type:
14+
- application/json
15+
Host:
16+
- generativelanguage.googleapis.com
17+
User-Agent:
18+
- google-genai-sdk/1.66.0 gl-python/3.13.3
19+
x-goog-api-client:
20+
- google-genai-sdk/1.66.0 gl-python/3.13.3
21+
method: POST
22+
uri: https://generativelanguage.googleapis.com/v1beta/interactions
23+
response:
24+
body:
25+
string: '{"id":"v1_ChdsaExWYWZYWE9mMkIxTWtQNk1EemlBbxIXbGhMVmFmWFhPZjJCMU1rUDZNRHppQW8","status":"completed","outputs":[{"signature":"CpMBAb4+9vv4hIyHoqn7P0G1RcfNsV+D0TVGVpbCfzmIK/crkqR6Qa0S42ec4l0Oq4Z0RbmycMFOP/vrRY+Sc4LXg05Rq9VWmajdjv6nOTQcjUcEiJtClTBse8396TbBWKKXRVDbmV1agysShvPyxEIv0Ics6mNi1npUq+w2TOFJ/KLgd19fIsh8eBVEV3pWdjvJd0ja","type":"thought"},{"text":"The
26+
capital of Italy is **Rome**.","type":"text"}],"usage":{"total_tokens":41,"total_input_tokens":8,"input_tokens_by_modality":[{"modality":"text","tokens":8}],"total_cached_tokens":0,"total_output_tokens":8,"total_tool_use_tokens":0,"total_thought_tokens":25},"role":"model","created":"2026-04-07T14:20:08Z","updated":"2026-04-07T14:20:08Z","object":"interaction","model":"gemini-2.5-flash"}'
27+
headers:
28+
Alt-Svc:
29+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
30+
Content-Type:
31+
- application/json
32+
Date:
33+
- Tue, 07 Apr 2026 14:20:08 GMT
34+
Server:
35+
- scaffolding on HTTPServer2
36+
Server-Timing:
37+
- gfet4t7; dur=1348
38+
Transfer-Encoding:
39+
- chunked
40+
Vary:
41+
- Origin
42+
- X-Origin
43+
- Referer
44+
X-Content-Type-Options:
45+
- nosniff
46+
X-Frame-Options:
47+
- SAMEORIGIN
48+
X-XSS-Protection:
49+
- '0'
50+
content-length:
51+
- '747'
52+
status:
53+
code: 200
54+
message: OK
55+
- request:
56+
body: ''
57+
headers:
58+
Accept:
59+
- application/json
60+
Accept-Encoding:
61+
- gzip, deflate, zstd
62+
Connection:
63+
- keep-alive
64+
Host:
65+
- generativelanguage.googleapis.com
66+
User-Agent:
67+
- google-genai-sdk/1.66.0 gl-python/3.13.3
68+
x-goog-api-client:
69+
- google-genai-sdk/1.66.0 gl-python/3.13.3
70+
method: GET
71+
uri: https://generativelanguage.googleapis.com/v1beta/interactions/v1_ChdsaExWYWZYWE9mMkIxTWtQNk1EemlBbxIXbGhMVmFmWFhPZjJCMU1rUDZNRHppQW8?include_input=true
72+
response:
73+
body:
74+
string: '{"id":"v1_ChdsaExWYWZYWE9mMkIxTWtQNk1EemlBbxIXbGhMVmFmWFhPZjJCMU1rUDZNRHppQW8","status":"completed","outputs":[{"signature":"CpMBAb4+9vv4hIyHoqn7P0G1RcfNsV+D0TVGVpbCfzmIK/crkqR6Qa0S42ec4l0Oq4Z0RbmycMFOP/vrRY+Sc4LXg05Rq9VWmajdjv6nOTQcjUcEiJtClTBse8396TbBWKKXRVDbmV1agysShvPyxEIv0Ics6mNi1npUq+w2TOFJ/KLgd19fIsh8eBVEV3pWdjvJd0ja","type":"thought"},{"text":"The
75+
capital of Italy is **Rome**.","type":"text"}],"usage":{"total_tokens":41,"total_input_tokens":8,"input_tokens_by_modality":[{"modality":"text","tokens":8}],"total_cached_tokens":0,"total_output_tokens":8,"total_tool_use_tokens":0,"total_thought_tokens":25},"role":"model","created":"2026-04-07T14:20:08Z","updated":"2026-04-07T14:20:08Z","object":"interaction","model":"gemini-2.5-flash","input":[{"role":"user","content":[{"text":"What
76+
is the capital of Italy?","type":"text"}]}]}'
77+
headers:
78+
Alt-Svc:
79+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
80+
Content-Type:
81+
- application/json
82+
Date:
83+
- Tue, 07 Apr 2026 14:20:08 GMT
84+
Server:
85+
- scaffolding on HTTPServer2
86+
Server-Timing:
87+
- gfet4t7; dur=130
88+
Transfer-Encoding:
89+
- chunked
90+
Vary:
91+
- Origin
92+
- X-Origin
93+
- Referer
94+
X-Content-Type-Options:
95+
- nosniff
96+
X-Frame-Options:
97+
- SAMEORIGIN
98+
X-XSS-Protection:
99+
- '0'
100+
content-length:
101+
- '840'
102+
status:
103+
code: 200
104+
message: OK
105+
- request:
106+
body: ''
107+
headers:
108+
Accept:
109+
- application/json
110+
Accept-Encoding:
111+
- gzip, deflate, zstd
112+
Connection:
113+
- keep-alive
114+
Content-Type:
115+
- application/json
116+
Host:
117+
- generativelanguage.googleapis.com
118+
User-Agent:
119+
- google-genai-sdk/1.66.0 gl-python/3.13.3
120+
x-goog-api-client:
121+
- google-genai-sdk/1.66.0 gl-python/3.13.3
122+
method: DELETE
123+
uri: https://generativelanguage.googleapis.com/v1beta/interactions/v1_ChdsaExWYWZYWE9mMkIxTWtQNk1EemlBbxIXbGhMVmFmWFhPZjJCMU1rUDZNRHppQW8
124+
response:
125+
body:
126+
string: '{}'
127+
headers:
128+
Alt-Svc:
129+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
130+
Content-Type:
131+
- application/json
132+
Date:
133+
- Tue, 07 Apr 2026 14:20:09 GMT
134+
Server:
135+
- scaffolding on HTTPServer2
136+
Server-Timing:
137+
- gfet4t7; dur=382
138+
Transfer-Encoding:
139+
- chunked
140+
Vary:
141+
- Origin
142+
- X-Origin
143+
- Referer
144+
X-Content-Type-Options:
145+
- nosniff
146+
X-Frame-Options:
147+
- SAMEORIGIN
148+
X-XSS-Protection:
149+
- '0'
150+
content-length:
151+
- '2'
152+
status:
153+
code: 200
154+
message: OK
155+
version: 1
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
interactions:
2+
- request:
3+
body: '{"input":"Say hi shortly.","model":"gemini-2.5-flash","stream":true}'
4+
headers:
5+
Accept:
6+
- application/json
7+
Accept-Encoding:
8+
- gzip, deflate, zstd
9+
Connection:
10+
- keep-alive
11+
Content-Length:
12+
- '68'
13+
Content-Type:
14+
- application/json
15+
Host:
16+
- generativelanguage.googleapis.com
17+
User-Agent:
18+
- google-genai-sdk/1.66.0 gl-python/3.13.3
19+
x-goog-api-client:
20+
- google-genai-sdk/1.66.0 gl-python/3.13.3
21+
method: POST
22+
uri: https://generativelanguage.googleapis.com/v1beta/interactions
23+
response:
24+
body:
25+
string: 'event: interaction.start
26+
27+
data: {"interaction":{"id":"v1_ChdtUkxWYWVqRUVZQ3YxTWtQb2IydS1RRRIXbVJMVmFlakVFWUN2MU1rUG9iMnUtUUU","status":"in_progress","object":"interaction","model":"gemini-2.5-flash"},"event_type":"interaction.start"}
28+
29+
30+
event: interaction.status_update
31+
32+
data: {"interaction_id":"v1_ChdtUkxWYWVqRUVZQ3YxTWtQb2IydS1RRRIXbVJMVmFlakVFWUN2MU1rUG9iMnUtUUU","status":"in_progress","event_type":"interaction.status_update"}
33+
34+
35+
event: content.start
36+
37+
data: {"index":0,"content":{"type":"thought"},"event_type":"content.start"}
38+
39+
40+
event: content.delta
41+
42+
data: {"index":0,"delta":{"signature":"ClUBvj72+9F73CQIW9AyrjKse6nIY6vxogBksIaH5zxIIsOMHbbkpLYbB3nSdvBf3485j4bntqHPZjSbypKwI84aO8RagejmAGNRu/Ss+Mebq15i5UIuCnUBvj72+0Ewr8MFjWarSxByDjIn8WzosxL4jSr61M/Cdf2bvYpcks9icyyuHi+zvrfpTOop2ODlpoa7Y/UexoemmbjdKpZeXy5wHb4R3eaiRAeucVPtpoMNFQi5TocaZXfK9hP5BP4p44e9zrJBVUYigBehaec=","type":"thought_signature"},"event_type":"content.delta"}
43+
44+
45+
event: content.stop
46+
47+
data: {"index":0,"event_type":"content.stop"}
48+
49+
50+
event: content.start
51+
52+
data: {"index":1,"content":{"type":"text"},"event_type":"content.start"}
53+
54+
55+
event: content.delta
56+
57+
data: {"index":1,"delta":{"text":"Hi!","type":"text"},"event_type":"content.delta"}
58+
59+
60+
event: content.stop
61+
62+
data: {"index":1,"event_type":"content.stop"}
63+
64+
65+
event: interaction.complete
66+
67+
data: {"interaction":{"id":"v1_ChdtUkxWYWVqRUVZQ3YxTWtQb2IydS1RRRIXbVJMVmFlakVFWUN2MU1rUG9iMnUtUUU","status":"completed","usage":{"total_tokens":42,"total_input_tokens":5,"input_tokens_by_modality":[{"modality":"text","tokens":5}],"total_cached_tokens":0,"total_output_tokens":2,"total_tool_use_tokens":0,"total_thought_tokens":35},"role":"model","created":"2026-04-07T14:20:10Z","updated":"2026-04-07T14:20:10Z","object":"interaction","model":"gemini-2.5-flash"},"event_type":"interaction.complete"}
68+
69+
70+
event: done
71+
72+
data: [DONE]
73+
74+
75+
'
76+
headers:
77+
Alt-Svc:
78+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
79+
Content-Type:
80+
- text/event-stream
81+
Date:
82+
- Tue, 07 Apr 2026 14:20:10 GMT
83+
Server:
84+
- scaffolding on HTTPServer2
85+
Server-Timing:
86+
- gfet4t7; dur=795
87+
Transfer-Encoding:
88+
- chunked
89+
Vary:
90+
- Origin
91+
- X-Origin
92+
- Referer
93+
X-Content-Type-Options:
94+
- nosniff
95+
X-Frame-Options:
96+
- SAMEORIGIN
97+
X-XSS-Protection:
98+
- '0'
99+
content-length:
100+
- '1816'
101+
status:
102+
code: 200
103+
message: OK
104+
version: 1
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
interactions:
2+
- request:
3+
body: '{"input":"What is the capital of France?","model":"gemini-2.5-flash"}'
4+
headers:
5+
Accept:
6+
- application/json
7+
Accept-Encoding:
8+
- gzip, deflate, zstd
9+
Connection:
10+
- keep-alive
11+
Content-Length:
12+
- '69'
13+
Content-Type:
14+
- application/json
15+
Host:
16+
- generativelanguage.googleapis.com
17+
User-Agent:
18+
- google-genai-sdk/1.66.0 gl-python/3.13.3
19+
x-goog-api-client:
20+
- google-genai-sdk/1.66.0 gl-python/3.13.3
21+
method: POST
22+
uri: https://generativelanguage.googleapis.com/v1beta/interactions
23+
response:
24+
body:
25+
string: '{"id":"v1_ChdqaExWYWVIQUQ4YTIxTWtQZ2ZxUDRRWRIXamhMVmFlSEFEOGEyMU1rUGdmcVA0UVk","status":"completed","outputs":[{"signature":"Cp8BAb4+9vtLsikCpBEO0omEzOmvrAc1XfoRIv4pg6pRC203MxRPHMkBCpCP1EfSaBQ8Ypk3CQsck/Yi+7N/+yj9vbqfCh2+idJjFcWg7Sxo64B10gs8O67D06FhP/gDpnv/hLOImOAKwnw3JYsQtVnAINE2zYTMVeirk116zvayi5D5iOzQ+2/SuQCtuUhIXWt2Jyy3LHcEUDfeJgO7uHXw","type":"thought"},{"text":"The
26+
capital of France is **Paris**.","type":"text"}],"usage":{"total_tokens":41,"total_input_tokens":8,"input_tokens_by_modality":[{"modality":"text","tokens":8}],"total_cached_tokens":0,"total_output_tokens":8,"total_tool_use_tokens":0,"total_thought_tokens":25},"role":"model","created":"2026-04-07T14:19:59Z","updated":"2026-04-07T14:19:59Z","object":"interaction","model":"gemini-2.5-flash"}'
27+
headers:
28+
Alt-Svc:
29+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
30+
Content-Type:
31+
- application/json
32+
Date:
33+
- Tue, 07 Apr 2026 14:19:59 GMT
34+
Server:
35+
- scaffolding on HTTPServer2
36+
Server-Timing:
37+
- gfet4t7; dur=1225
38+
Transfer-Encoding:
39+
- chunked
40+
Vary:
41+
- Origin
42+
- X-Origin
43+
- Referer
44+
X-Content-Type-Options:
45+
- nosniff
46+
X-Frame-Options:
47+
- SAMEORIGIN
48+
X-XSS-Protection:
49+
- '0'
50+
content-length:
51+
- '765'
52+
status:
53+
code: 200
54+
message: OK
55+
- request:
56+
body: ''
57+
headers:
58+
Accept:
59+
- application/json
60+
Accept-Encoding:
61+
- gzip, deflate, zstd
62+
Connection:
63+
- keep-alive
64+
Host:
65+
- generativelanguage.googleapis.com
66+
User-Agent:
67+
- google-genai-sdk/1.66.0 gl-python/3.13.3
68+
x-goog-api-client:
69+
- google-genai-sdk/1.66.0 gl-python/3.13.3
70+
method: GET
71+
uri: https://generativelanguage.googleapis.com/v1beta/interactions/v1_ChdqaExWYWVIQUQ4YTIxTWtQZ2ZxUDRRWRIXamhMVmFlSEFEOGEyMU1rUGdmcVA0UVk?include_input=true
72+
response:
73+
body:
74+
string: '{"id":"v1_ChdqaExWYWVIQUQ4YTIxTWtQZ2ZxUDRRWRIXamhMVmFlSEFEOGEyMU1rUGdmcVA0UVk","status":"completed","outputs":[{"signature":"Cp8BAb4+9vtLsikCpBEO0omEzOmvrAc1XfoRIv4pg6pRC203MxRPHMkBCpCP1EfSaBQ8Ypk3CQsck/Yi+7N/+yj9vbqfCh2+idJjFcWg7Sxo64B10gs8O67D06FhP/gDpnv/hLOImOAKwnw3JYsQtVnAINE2zYTMVeirk116zvayi5D5iOzQ+2/SuQCtuUhIXWt2Jyy3LHcEUDfeJgO7uHXw","type":"thought"},{"text":"The
75+
capital of France is **Paris**.","type":"text"}],"usage":{"total_tokens":41,"total_input_tokens":8,"input_tokens_by_modality":[{"modality":"text","tokens":8}],"total_cached_tokens":0,"total_output_tokens":8,"total_tool_use_tokens":0,"total_thought_tokens":25},"role":"model","created":"2026-04-07T14:19:59Z","updated":"2026-04-07T14:19:59Z","object":"interaction","model":"gemini-2.5-flash","input":[{"role":"user","content":[{"text":"What
76+
is the capital of France?","type":"text"}]}]}'
77+
headers:
78+
Alt-Svc:
79+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
80+
Content-Type:
81+
- application/json
82+
Date:
83+
- Tue, 07 Apr 2026 14:19:59 GMT
84+
Server:
85+
- scaffolding on HTTPServer2
86+
Server-Timing:
87+
- gfet4t7; dur=102
88+
Transfer-Encoding:
89+
- chunked
90+
Vary:
91+
- Origin
92+
- X-Origin
93+
- Referer
94+
X-Content-Type-Options:
95+
- nosniff
96+
X-Frame-Options:
97+
- SAMEORIGIN
98+
X-XSS-Protection:
99+
- '0'
100+
content-length:
101+
- '859'
102+
status:
103+
code: 200
104+
message: OK
105+
version: 1

0 commit comments

Comments
 (0)