Skip to content

Commit e60aacd

Browse files
Qardclaude
andcommitted
test(e2e): Add e2e assertions for messages.batches API instrumentation
Adds scenario coverage and snapshot assertions for the Anthropic Message Batches API (create, retrieve, list, cancel) across all supported SDK versions (v0.39.0+). Normalizes volatile batch response fields (timestamps, batch IDs, list bodies) for stable snapshots. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f340ac9 commit e60aacd

23 files changed

+1330
-42
lines changed

e2e/scenarios/anthropic-instrumentation/__snapshots__/anthropic-v0390.log-payloads.json

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,149 @@
302302
},
303303
"type": "llm"
304304
},
305+
{
306+
"metadata": {
307+
"operation": "batches"
308+
},
309+
"metrics": {
310+
"end": 0,
311+
"start": 0
312+
},
313+
"name": "anthropic-batches-operation",
314+
"type": null
315+
},
316+
{
317+
"input": [
318+
{
319+
"custom_id": "braintrust-e2e-test",
320+
"params": {
321+
"max_tokens": 16,
322+
"messages": [
323+
{
324+
"content": "Reply with exactly OK.",
325+
"role": "user"
326+
}
327+
],
328+
"model": "claude-3-haiku-20240307"
329+
}
330+
}
331+
],
332+
"metadata": {
333+
"provider": "anthropic"
334+
},
335+
"metrics": {
336+
"end": 0,
337+
"start": 0
338+
},
339+
"name": "anthropic.messages.batches.create",
340+
"output": {
341+
"archived_at": null,
342+
"cancel_initiated_at": null,
343+
"created_at": "<timestamp>",
344+
"ended_at": null,
345+
"expires_at": "<timestamp>",
346+
"id": "<span:3>",
347+
"processing_status": "<processing_status>",
348+
"request_counts": {
349+
"canceled": 0,
350+
"errored": 0,
351+
"expired": 0,
352+
"processing": 0,
353+
"succeeded": 0
354+
},
355+
"results_url": null,
356+
"type": "message_batch"
357+
},
358+
"type": "llm"
359+
},
360+
{
361+
"input": "<msgbatch_id>",
362+
"metadata": {
363+
"provider": "anthropic"
364+
},
365+
"metrics": {
366+
"end": 0,
367+
"start": 0
368+
},
369+
"name": "anthropic.messages.batches.retrieve",
370+
"output": {
371+
"archived_at": null,
372+
"cancel_initiated_at": null,
373+
"created_at": "<timestamp>",
374+
"ended_at": null,
375+
"expires_at": "<timestamp>",
376+
"id": "<span:3>",
377+
"processing_status": "<processing_status>",
378+
"request_counts": {
379+
"canceled": 0,
380+
"errored": 0,
381+
"expired": 0,
382+
"processing": 0,
383+
"succeeded": 0
384+
},
385+
"results_url": null,
386+
"type": "message_batch"
387+
},
388+
"type": "llm"
389+
},
390+
{
391+
"input": null,
392+
"metadata": {
393+
"provider": "anthropic"
394+
},
395+
"metrics": {
396+
"end": 0,
397+
"start": 0
398+
},
399+
"name": "anthropic.messages.batches.list",
400+
"output": {
401+
"body": "<batch-list-body>",
402+
"data": "<batch-list-data>",
403+
"first_id": "<msgbatch_id>",
404+
"has_more": true,
405+
"last_id": "<msgbatch_id>",
406+
"options": {
407+
"method": "get",
408+
"path": "/v1/messages/batches",
409+
"query": {}
410+
},
411+
"response": {
412+
"size": 0,
413+
"timeout": 0
414+
}
415+
},
416+
"type": "llm"
417+
},
418+
{
419+
"input": "<msgbatch_id>",
420+
"metadata": {
421+
"provider": "anthropic"
422+
},
423+
"metrics": {
424+
"end": 0,
425+
"start": 0
426+
},
427+
"name": "anthropic.messages.batches.cancel",
428+
"output": {
429+
"archived_at": null,
430+
"cancel_initiated_at": "<timestamp>",
431+
"created_at": "<timestamp>",
432+
"ended_at": null,
433+
"expires_at": "<timestamp>",
434+
"id": "<span:3>",
435+
"processing_status": "<processing_status>",
436+
"request_counts": {
437+
"canceled": 0,
438+
"errored": 0,
439+
"expired": 0,
440+
"processing": 0,
441+
"succeeded": 0
442+
},
443+
"results_url": null,
444+
"type": "message_batch"
445+
},
446+
"type": "llm"
447+
},
305448
{
306449
"metadata": {
307450
"operation": "beta-create"

e2e/scenarios/anthropic-instrumentation/__snapshots__/anthropic-v0390.span-events.json

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,81 @@
240240
],
241241
"type": "llm"
242242
},
243+
{
244+
"has_input": false,
245+
"has_output": false,
246+
"metadata": {
247+
"operation": "batches"
248+
},
249+
"metric_keys": [],
250+
"name": "anthropic-batches-operation",
251+
"root_span_id": "<span:1>",
252+
"span_id": "<span:14>",
253+
"span_parents": [
254+
"<span:1>"
255+
],
256+
"type": null
257+
},
258+
{
259+
"has_input": true,
260+
"has_output": true,
261+
"metadata": {
262+
"provider": "anthropic"
263+
},
264+
"metric_keys": [],
265+
"name": "anthropic.messages.batches.create",
266+
"root_span_id": "<span:1>",
267+
"span_id": "<span:15>",
268+
"span_parents": [
269+
"<span:14>"
270+
],
271+
"type": "llm"
272+
},
273+
{
274+
"has_input": true,
275+
"has_output": true,
276+
"metadata": {
277+
"provider": "anthropic"
278+
},
279+
"metric_keys": [],
280+
"name": "anthropic.messages.batches.retrieve",
281+
"root_span_id": "<span:1>",
282+
"span_id": "<span:16>",
283+
"span_parents": [
284+
"<span:14>"
285+
],
286+
"type": "llm"
287+
},
288+
{
289+
"has_input": false,
290+
"has_output": true,
291+
"metadata": {
292+
"provider": "anthropic"
293+
},
294+
"metric_keys": [],
295+
"name": "anthropic.messages.batches.list",
296+
"root_span_id": "<span:1>",
297+
"span_id": "<span:17>",
298+
"span_parents": [
299+
"<span:14>"
300+
],
301+
"type": "llm"
302+
},
303+
{
304+
"has_input": true,
305+
"has_output": true,
306+
"metadata": {
307+
"provider": "anthropic"
308+
},
309+
"metric_keys": [],
310+
"name": "anthropic.messages.batches.cancel",
311+
"root_span_id": "<span:1>",
312+
"span_id": "<span:18>",
313+
"span_parents": [
314+
"<span:14>"
315+
],
316+
"type": "llm"
317+
},
243318
{
244319
"has_input": false,
245320
"has_output": false,
@@ -249,7 +324,7 @@
249324
"metric_keys": [],
250325
"name": "anthropic-beta-create-operation",
251326
"root_span_id": "<span:1>",
252-
"span_id": "<span:14>",
327+
"span_id": "<span:19>",
253328
"span_parents": [
254329
"<span:1>"
255330
],
@@ -272,9 +347,9 @@
272347
],
273348
"name": "anthropic.messages.create",
274349
"root_span_id": "<span:1>",
275-
"span_id": "<span:15>",
350+
"span_id": "<span:20>",
276351
"span_parents": [
277-
"<span:14>"
352+
"<span:19>"
278353
],
279354
"type": "llm"
280355
},
@@ -287,7 +362,7 @@
287362
"metric_keys": [],
288363
"name": "anthropic-beta-stream-operation",
289364
"root_span_id": "<span:1>",
290-
"span_id": "<span:16>",
365+
"span_id": "<span:21>",
291366
"span_parents": [
292367
"<span:1>"
293368
],
@@ -310,9 +385,9 @@
310385
],
311386
"name": "anthropic.messages.create",
312387
"root_span_id": "<span:1>",
313-
"span_id": "<span:17>",
388+
"span_id": "<span:22>",
314389
"span_parents": [
315-
"<span:16>"
390+
"<span:21>"
316391
],
317392
"type": "llm"
318393
}

0 commit comments

Comments
 (0)