feat: Add Message Batches API instrumentation#1698
Open
Stephen Belanger (Qard) wants to merge 2 commits intomainfrom
Open
feat: Add Message Batches API instrumentation#1698Stephen Belanger (Qard) wants to merge 2 commits intomainfrom
Stephen Belanger (Qard) wants to merge 2 commits intomainfrom
Conversation
- Add vendor types for AnthropicBatches, AnthropicMessageBatch, and batch params - Add diagnostic channels for create, retrieve, list, cancel, and delete batch ops - Add batchesProxy() in wrapAnthropic() to intercept all Batches methods - Add AnthropicPlugin subscriptions for batch channels via traceAsyncChannel - Add auto-instrumentation configs targeting Batches class methods (>=0.39.0) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ractInput The destructured parameter type annotations (e.g. `([params]: [T])`) were stricter than the expected `(args: [T, ...any[]], event, span) => ...` type, causing assignability errors. Removing the annotations lets TypeScript infer the correct types from the channel's generic parameters. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Luca Forstner (lforst)
previously approved these changes
Mar 27, 2026
Member
Luca Forstner (lforst)
left a comment
There was a problem hiding this comment.
Generally looks good but some e2e test assertions would be beneficial I think.
Member
|
Actually, coming back to my senses... Should we really be instrumenting create, retrieve, list, cancel, delete? Those seem more like CRUD operations and less like AI relevant things that we would like to instrument no?
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
messages.batches.*) — fixes Anthropic Message Batches API (client.messages.batches.*) not instrumented #1691wrapAnthropic()manual wrapping and auto-instrumentation via--import braintrust/hook.mjscreate,retrieve,list,cancel,deleteChanges
vendor-sdk-types/anthropic.ts: AddedAnthropicBatches,AnthropicMessageBatch,AnthropicBatchCreateParams,AnthropicBatchRequest,AnthropicBatchListParamstypes; addedbatchesfield toAnthropicMessagesanthropic-channels.ts: Added 5 new diagnostic channels (messages.batches.create/retrieve/list/cancel/delete)wrappers/anthropic.ts: AddedbatchesProxy()and wired it intomessagesProxy()to intercept thebatchespropertyanthropic-plugin.ts: AddedtraceAsyncChannelsubscriptions for all 5 batch channelsconfigs/anthropic.ts: Added auto-instrumentation configs targetingBatchesclass methods inresources/messages/batches.mjs(>=0.39.0)Test plan
pnpm run test:checksinjs/)pnpm run lint)pnpm run fix:formatting)🤖 Generated with Claude Code