Registry / observability / opentelemetry-instrumentation-bedrock

opentelemetry-instrumentation-bedrock

JSON →
library0.62.3pypypi✓ verified 29d ago

The `opentelemetry-instrumentation-bedrock` library provides automatic instrumentation for AWS Bedrock API calls made using Boto3. It captures telemetry data such as prompts, completions, and embeddings, enabling observability into Large Language Model (LLM) applications within the OpenTelemetry ecosystem. This library is part of the broader OpenLLMetry project and is currently at version 0.58.0, with a frequent release cadence.

pip install opentelemetry-instrumentation-bedrock boto3
INSTALL
IMPORT
SIG · OPENTELEMETRY-INST
O
opentelemetry-instrumentation-bedrock
observabilitypythonv0.62.3
Install
7.0s avg
Import
1168ms
Disk
73MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.62.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.208s · 57.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 7.0s · import 1.128s · 58MB
73MB installed
● package 73MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BedrockInstrumentor
✓ from opentelemetry.instrumentation.bedrock import BedrockInstrumentor

This quickstart demonstrates how to set up the OpenTelemetry SDK with a console exporter, instrument the Bedrock client, and then invoke a Bedrock model. The instrumentation automatically creates spans for the Bedrock interaction, which are then printed to the console by the `ConsoleSpanExporter`.

import os import boto3 from opentelemetry import trace from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor from opentelemetry.instrumentation.bedrock import BedrockInstrumentor # Configure OpenTelemetry SDK resource = Resource.create({"service.name": "bedrock-app"}) tracer_provider = TracerProvider(resource=resource) span_processor = SimpleSpanProcessor(ConsoleSpanExporter()) tracer_provider.add_span_processor(span_processor) trace.set_tracer_provider(tracer_provider) # Instrument Bedrock BedrockInstrumentor().instrument() # Ensure AWS credentials are set up (e.g., via environment variables or AWS CLI config) # For a runnable example, ensure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION are set or mock boto3. # For this quickstart, we'll use os.environ.get for region, assuming credentials are in place. aws_region = os.environ.get('AWS_REGION', 'us-east-1') def invoke_bedrock_model(): try: bedrock_runtime = boto3.client( service_name='bedrock-runtime', region_name=aws_region ) model_id = 'amazon.titan-text-express-v1' body = { 'inputText': 'Explain the importance of OpenTelemetry.', 'textGenerationConfig': { 'maxTokenCount': 50, 'stopSequences': [], 'temperature': 0.7, 'topP': 0.9 } } response = bedrock_runtime.invoke_model( body=json.dumps(body), modelId=model_id, accept='application/json', contentType='application/json' ) response_body = json.loads(response.get('body').read()) print(f"Bedrock Model Response: {response_body['results'][0]['outputText'].strip()}") except Exception as e: print(f"Error invoking Bedrock model: {e}") import json invoke_bedrock_model()
opentelemetry-instrument --version
Debug
Known issues
breakingThe OpenTelemetry Generative AI (GenAI) semantic conventions have undergone significant changes, particularly in attribute naming and structure. Recent versions of `opentelemetry-instrumentation-bedrock` (e.g., 0.53.4, 0.54.0, 0.55.0, 0.57.0) reflect these updates to conform to the latest OTel GenAI semantic conventions (e.g., 0.5.0).
fix
Review existing dashboards, alerts, and querying logic that rely on OpenTelemetry span attributes. Update them to use the new semantic convention attribute names. For a transition period, you might use the `OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental` environment variable to explicitly enable the latest experimental conventions or facilitate dual emission, though direct adaptation is recommended for stable setups. Consult the OpenTelemetry semantic conventions documentation for specific changes.
affects: >=0.53.0
gotchaBy default, this instrumentation logs prompts, completions, and embeddings to span attributes, which can contain sensitive user data. This is done to provide rich observability, but may pose privacy concerns.
fix
To disable logging of this content, set the environment variable `TRACELOOP_TRACE_CONTENT` to `false`.
affects: All
gotchaEnsure your `boto3` and `botocore` library versions are compatible with the specific AWS Bedrock features you intend to use. Older versions might not support newer Bedrock APIs (e.g., `botocore >= 1.34.116` is required for the `converse` API).
fix
Check the AWS SDK documentation for `boto3` and `botocore` for version requirements related to specific Bedrock functionalities you are using. Upgrade `boto3` and `botocore` if necessary: `pip install --upgrade boto3 botocore`.
affects: All
Upgrade
Version history
0.62.3latest on PyPI · released Aug 10, 2026
Audit
Dependencies
boto3requiredRequired for interacting with AWS Bedrock services, which this instrumentation intercepts.
opentelemetry-sdkrequiredCore OpenTelemetry SDK components are necessary for processing and exporting telemetry data.
opentelemetry-apirequiredCore OpenTelemetry API for creating traces, metrics, and logs.
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources
opentelemetry-instrumentation-bedrock — pip install opentelemetry-instrumentation-bedrock · libregistry