feat(anthropic): instrument Messages Batch API#127
Merged
Abhijeet Prasad (AbhiPrasad) merged 1 commit intomainfrom Mar 24, 2026
Merged
feat(anthropic): instrument Messages Batch API#127Abhijeet Prasad (AbhiPrasad) merged 1 commit intomainfrom
Abhijeet Prasad (AbhiPrasad) merged 1 commit intomainfrom
Conversation
Add tracing for client.messages.batches.create() and client.messages.batches.results(), covering both sync/async clients and the beta namespace. Batch operations now produce spans with batch ID, request count, model, and processing status metadata. The Messages and AsyncMessages wrapper classes gain a batches property that returns a traced Batches/AsyncBatches resource instead of falling through to the unwrapped original via Wrapper.__getattr__. Also clean up the test file: remove tests that asserted on wrapping internals (already covered by wrapper compat subprocess tests), convert batch create tests to VCR cassettes, and keep mocks only for batches.results() which requires a completed batch (up to 24 hours). Closes #108
ViaDézo1er / cedric (viadezo1er)
approved these changes
Mar 24, 2026
Contributor
ViaDézo1er / cedric (viadezo1er)
left a comment
There was a problem hiding this comment.
Otherwise looks good, assuming the CI passes.
|
|
||
| import inspect | ||
| import time | ||
| import unittest.mock |
Contributor
There was a problem hiding this comment.
I think VCR are usually preferred in this repo, were they too hard to record/use for this use-case?
Member
Author
There was a problem hiding this comment.
Yes unfortunately I couldn't make it work. I left the reasoning as a docstring on the test but:
Mocked because the batch results API requires a completed batch, and batches
can take up to 24 hours to finish processing.
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.
resolves #108
Add tracing for
client.messages.batches.create()andclient.messages.batches.results(), covering both sync/async clientsand the beta namespace. Batch operations now produce spans with
batch ID, request count, model, and processing status metadata.
The
MessagesandAsyncMessageswrapper classes gain a batches propertythat returns a traced
Batches/AsyncBatchesresource instead of fallingthrough to the unwrapped original via
Wrapper.__getattr__.Also clean up the test file: remove tests that asserted on wrapping
internals (already covered by wrapper compat subprocess tests), convert
batch create tests to VCR cassettes, and keep mocks only for
batches.results() which requires a completed batch (up to 24 hours).