feat(bedrock): Migrate AWS Bedrock Runtime instrumentation#93
Draft
williazz wants to merge 6 commits into
Draft
Conversation
Scaffold the opentelemetry-instrumentation-genai-bedrock package to instrument the botocore Bedrock Runtime Converse and ConverseStream APIs using the TelemetryHandler/InferenceInvocation lifecycle from opentelemetry-util-genai. The patch wraps botocore.client.BaseClient._make_api_call, filtering for bedrock-runtime service calls to Converse/ConverseStream operations. Assisted-by: Claude Opus 4.6
Register the bedrock package in the root pyproject.toml workspace, add tox test environments, and include basic tests validating span attributes, error recording, and content capture via botocore Stubber. Assisted-by: Claude Opus 4.6
- Add boto3 to test requirements (tests use boto3.client directly) - Apply ruff format to wrappers.py and test_converse.py - Regenerate instrumentation/README.md via tox -e generate - Add changelog fragment for PR open-telemetry#93 - Update uv.lock to include bedrock package Assisted-by: Claude Opus 4.6
Author
|
Pushed fixes for CI failures:
The changelog job will still show a warning because this PR creates a new |
The changelog workflow rejects PRs that include any **/CHANGELOG.md in the diff. The .changelog/93.added fragment satisfies the requirement for a changelog entry. CHANGELOG.md will be generated by towncrier on first release.
Use GenAiSystemValues.AWS_BEDROCK enum instead of string literal "aws.bedrock" per project semconv rules. Remove unused logging import and _logger definition from patch.py. Assisted-by: Claude Opus 4.6
Author
Add attribution to the source modules crediting Riccardo Magliocchetti (@xrmx) as the original author of the Bedrock extension in opentelemetry-python-contrib, with links to the upstream PRs. Assisted-by: Claude Opus 4.6
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
opentelemetry-instrumentation-genai-bedrockas a new package in this monorepoTelemetryHandler/InferenceInvocationlifecycle fromopentelemetry-util-genaibotocore.client.BaseClient._make_api_calldirectly (no dependency onopentelemetry-instrumentation-botocore)Provenance
This is extracted from the existing Bedrock instrumentation in
opentelemetry-python-contrib, originally authored by @riccardo-magliocchetti:Source modules:
extensions/bedrock.pyextensions/bedrock_utils.pytests/test_botocore_bedrock.pyUpstream PRs:
The code has been rewritten to use the shared GenAI utilities (
TelemetryHandler,InferenceInvocation, semconv enums) in this repo rather than the botocore extension pattern.What's included
pyproject.toml, entry points, and changelog supportConverse) instrumentation with full attribute extractionConverseStream) instrumentation with event accumulationWhat's NOT included yet (follow-up work)
InvokeModel/InvokeModelWithResponseStreamsupport (model-specific formats)Context
Per discussion in the GenAI SIG, Bedrock GenAI instrumentation should live in this repo rather than the general-purpose botocore instrumentation in
opentelemetry-python-contrib. This PR is a proposal/draft to get early feedback on the approach before we coordinate deprecation of the Bedrock-specific code in the botocore extension.Test plan
pytestpasses for all 6 tests (instrumentor lifecycle + Converse span attributes, error handling, content capture)rufflint passes