File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
util/opentelemetry-util-genai
src/opentelemetry/util/genai/_upload Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -203,15 +203,16 @@ def _do_upload(
203
203
def on_completion (
204
204
self ,
205
205
* ,
206
- inputs : list [types .InputMessage ] | None = None ,
207
- outputs : list [types .OutputMessage ] | None = None ,
208
- system_instruction : list [types .MessagePart ] | None = None ,
206
+ inputs : list [types .InputMessage ],
207
+ outputs : list [types .OutputMessage ],
208
+ system_instruction : list [types .MessagePart ],
209
209
span : Span | None = None ,
210
210
log_record : LogRecord | None = None ,
211
211
** kwargs : Any ,
212
212
) -> None :
213
213
if not any ([inputs , outputs , system_instruction ]):
214
214
return
215
+ # An empty list will not be uploaded.
215
216
completion = Completion (
216
217
inputs = inputs or None ,
217
218
outputs = outputs or None ,
Original file line number Diff line number Diff line change @@ -163,10 +163,12 @@ def test_upload_then_shutdown(self):
163
163
)
164
164
165
165
def test_upload_when_inputs_outputs_empty (self ):
166
+ record = LogRecord ()
166
167
self .hook .on_completion (
167
168
inputs = [],
168
169
outputs = [],
169
170
system_instruction = FAKE_SYSTEM_INSTRUCTION ,
171
+ log_record = record ,
170
172
)
171
173
# all items should be consumed
172
174
self .hook .shutdown ()
@@ -176,6 +178,16 @@ def test_upload_when_inputs_outputs_empty(self):
176
178
1 ,
177
179
"should have uploaded 1 file" ,
178
180
)
181
+ assert record .attributes is not None
182
+ for ref_key in [
183
+ "gen_ai.input.messages_ref" ,
184
+ "gen_ai.output.messages_ref" ,
185
+ "gen_ai.system_instructions_ref" ,
186
+ ]:
187
+ if ref_key == "gen_ai.system_instructions_ref" :
188
+ self .assertIn (ref_key , record .attributes )
189
+ else :
190
+ self .assertNotIn (ref_key , record .attributes )
179
191
180
192
def test_upload_blocked (self ):
181
193
with self .block_upload ():
You can’t perform that action at this time.
0 commit comments