Skip to content

feat(anthropic): support Bedrock beta messages - #20061

Open
mlorthiois wants to merge 1 commit into
DataDog:mainfrom
mlorthiois:feat/anthropic-bedrock-beta-messages
Open

feat(anthropic): support Bedrock beta messages#20061
mlorthiois wants to merge 1 commit into
DataDog:mainfrom
mlorthiois:feat/anthropic-bedrock-beta-messages

Conversation

@mlorthiois

Copy link
Copy Markdown

Description

Adds APM and LLM Observability tracing support for beta Messages API calls made through the Anthropic SDK's first-party AnthropicBedrock and AsyncAnthropicBedrock clients.

The Bedrock beta resource classes capture their own references to the Messages create methods during import anthropic, before the existing Anthropic instrumentation is installed. This change instruments those Bedrock-specific sync and async methods directly, adds symmetric unpatching, and keeps AI Guard's outer streaming wrappers aligned with the Anthropic integration targets.

Closes #18075.

Testing

  • Added patch lifecycle coverage for the sync and async Bedrock beta Messages methods.
  • Added an async LLM Observability regression test that verifies AsyncAnthropicBedrock.beta.messages.create() emits an LLM span with Amazon as the model provider.
  • Added coverage ensuring AI Guard installs wrappers on both Bedrock beta Messages methods.
  • Validated the Anthropic integration against the latest Anthropic SDK on Python 3.13: 23 targeted tests passed.
  • Validated backward compatibility with anthropic~=0.28.0 on Python 3.12: 92 passed, 17 skipped.
  • Validated the AI Guard Anthropic streaming suite on Python 3.13: 20 passed.
  • Ran scripts/lint checks successfully.

Risks

Low. The new instrumentation targets an Anthropic SDK private module, but it is guarded by the existing anthropic>=0.37 beta API version check and covered by patch, unpatch, and double-patch tests.

@mlorthiois
mlorthiois requested review from a team as code owners September 3, 2026 20:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T20:10:58.875867Z 39cfe05 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Anthropic integration does not instrument AsyncAnthropicBedrock.beta.messages.create — LLM Observability misses Bedrock calls

1 participant