Skip to content

fix(bedrock): detect global cross-region inference profile prefix#4235

Open
kimnamu wants to merge 1 commit into
traceloop:mainfrom
kimnamu:fix/bedrock-global-inference-profile
Open

fix(bedrock): detect global cross-region inference profile prefix#4235
kimnamu wants to merge 1 commit into
traceloop:mainfrom
kimnamu:fix/bedrock-global-inference-profile

Conversation

@kimnamu

@kimnamu kimnamu commented Jun 13, 2026

Copy link
Copy Markdown

Thanks for OpenLLMetry. This fills in one missing entry in the cross-region prefix list added in #2785.

Fixes #4234

Problem

AWS's global. cross-region inference profile prefix (currently Claude Sonnet 4 — AWS docs) isn't recognized by _cross_region_check, which knows us / us-gov / eu / apac. So global.anthropic.claude-sonnet-4-... falls to the else branch.

Cause

The else path does value.split(".", 1)model_vendor="global", model keeps the anthropic. prefix. span_utils (set_model_message_span_attributes, set_model_choice_span_attributes, _set_finish_reasons_unconditionally) branches on the vendor with no else, so an unrecognized vendor drops all prompt/completion/finish-reason attributes.

Change

Add "global" to the prefix list — symmetric to the regional prefixes already handled.

Item Before (global.anthropic.claude-sonnet-4-...) After
model_vendor "global" "anthropic"
gen_ai.request.model anthropic.claude-sonnet-4-... claude-sonnet-4-...
Prompt / completion / finish-reason attrs ❌ dropped ✅ emitted
Regional prefixes us/us-gov/eu/apac ✅ unchanged ✅ unchanged
Non-prefixed IDs (anthropic.claude-...) ✅ unchanged ✅ unchanged

Tests

New tests/test_cross_region_inference_profile.py (5 tests). Revert-the-fix check: with the one-line change reverted the new test fails (assert 'global' == 'anthropic'); restored, all pass. Full bedrock unit suite: 64 passed. ruff check clean.


This contribution was prepared with the help of an AI agent (Claude Code); a human reviewed the change, the AWS-doc rationale, and the test results before submission.

Summary by CodeRabbit

  • New Features

    • Extended cross-region inference profile parsing to recognize global prefix alongside existing region identifiers.
  • Tests

    • Added comprehensive test coverage for cross-region inference profile ID parsing and vendor resolution with the new global prefix support.

The global. cross-region inference profile prefix (currently Claude
Sonnet 4) was not recognized in _cross_region_check, so model IDs like
global.anthropic.claude-sonnet-4-... fell to the else branch and resolved
to model_vendor="global". span_utils branches on the vendor with no else
clause, so prompt, completion, and finish-reason attributes were silently
dropped and the model name kept its anthropic. prefix. Add "global" to
the regional prefix list alongside us / us-gov / eu / apac.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Jun 13, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c9a5d437-ccbe-4d13-b051-d931176db1c5

📥 Commits

Reviewing files that changed from the base of the PR and between 4643b88 and 7419609.

📒 Files selected for processing (2)
  • packages/opentelemetry-instrumentation-bedrock/opentelemetry/instrumentation/bedrock/__init__.py
  • packages/opentelemetry-instrumentation-bedrock/tests/test_cross_region_inference_profile.py

📝 Walkthrough

Walkthrough

The PR adds support for AWS's new global. cross-region inference profile prefix in Bedrock instrumentation. The implementation expands the recognized prefix list to include "global", and new test coverage validates correct vendor and model ID resolution for global inference profiles.

Changes

Bedrock Global Inference Profile Support

Layer / File(s) Summary
Global prefix support in cross-region check
packages/opentelemetry-instrumentation-bedrock/opentelemetry/instrumentation/bedrock/__init__.py
_cross_region_check now treats "global" as an eligible cross-region prefix alongside "us", "us-gov", "eu", and "apac", enabling correct vendor and model ID extraction for global inference profiles.
Cross-region inference profile test coverage
packages/opentelemetry-instrumentation-bedrock/tests/test_cross_region_inference_profile.py
New test module with TestCrossRegionCheck and TestGetVendorModelGlobalProfile classes validates that global. prefix is recognized and that vendor resolution and model ID extraction work correctly for both raw model IDs and ARN-formatted identifiers.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A global prefix hops into view,
Claude Sonnet spans now gleaming true,
No more attributes lost in flight—
Global inference profiles shining bright! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding 'global' to the cross-region inference profile prefix detection in Bedrock instrumentation, which directly addresses the core issue.
Linked Issues check ✅ Passed The PR fully satisfies issue #4234's requirements: adds 'global' to the prefix list in _cross_region_check, includes regression tests, and resolves the vendor detection and span attribute issues described.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the 'global' prefix detection issue: the single-line code fix and comprehensive test coverage are both necessary and on-topic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Bedrock: global. cross-region inference profile resolves to vendor "global", dropping span attributes

2 participants