Skip to main content

OpenTelemetry Bedrock Runtime Instrumentation

This package instruments AWS Bedrock Runtime model calls made through boto3/botocore and emits GenAI LLMInvocation telemetry through splunk-otel-util-genai.

Installation

pip install splunk-otel-instrumentation-bedrock

Usage

import boto3
from opentelemetry.instrumentation.bedrock import BedrockInstrumentor

BedrockInstrumentor().instrument()

client = boto3.client("bedrock-runtime", region_name="us-west-2")
response = client.converse(
    modelId="anthropic.claude-3-haiku-20240307-v1:0",
    messages=[{"role": "user", "content": [{"text": "Hello"}]}],
)

Composition With AgentCore

Use this package with AgentCore instrumentation when your application uses BedrockAgentCoreApp and calls Bedrock Runtime from inside the entrypoint. AgentCore owns the agent parent spans, and this package adds the child LLM spans that evaluation callbacks consume.

from opentelemetry.instrumentation.bedrock import BedrockInstrumentor
from opentelemetry.instrumentation.bedrock_agentcore import (
    BedrockAgentCoreInstrumentor,
)

BedrockAgentCoreInstrumentor().instrument()
BedrockInstrumentor().instrument()

Example

In the repository, see examples/manual for a runnable Bedrock Runtime example that can also enable AgentCore instrumentation. It uses console span export by default so you can verify that Bedrock Runtime LLM spans nest under active AgentCore spans when both instrumentors are enabled.

What Gets Instrumented

  • bedrock-runtime.Converse -> LLMInvocation

  • bedrock-runtime.ConverseStream -> streaming LLMInvocation

  • bedrock-runtime.InvokeModel -> provider-aware LLMInvocation

  • bedrock-runtime.InvokeModelWithResponseStream -> provider-aware streaming LLMInvocation for supported streamed JSON chunk formats

Agent Runtime calls such as bedrock-agent-runtime.invoke_agent are not instrumented by this package. Agent orchestration spans belong in AgentCore or agent-framework instrumentation.

Configuration

Content capture follows the shared GenAI environment variables:

export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_AND_EVENT
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_TOOL_DEFINITIONS=true

Useful flags for Bedrock Runtime and AgentCore composition:

Environment variable

Purpose

OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT

Controls whether captured prompt and completion message content is emitted by the shared GenAI emitters. Use SPAN_AND_EVENT when evals and exported telemetry both need message bodies.

OTEL_INSTRUMENTATION_GENAI_CAPTURE_TOOL_DEFINITIONS

Controls whether Bedrock tool definitions are serialized into emitted telemetry. Leave disabled when tool schemas are large or sensitive.

DISABLE_ADOT_OBSERVABILITY

Set to true in AgentCore deployments that export to your own OTLP collector so AgentCore does not also send telemetry through AWS ADOT observability.

The instrumentation always populates message bodies and tool arguments on the Python invocation objects so evaluations can consume them. The shared GenAI emitters use the content-capture setting to decide whether those values are emitted as span attributes or log events.

For zero-code instrumentation, disable this package with OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=bedrock.

InvokeModel Coverage

InvokeModel and InvokeModelWithResponseStream support generic JSON metadata extraction plus provider-specific shapes aligned with upstream OpenTelemetry botocore Bedrock behavior:

  • Amazon Titan

  • Amazon Nova

  • Anthropic Claude

  • Cohere Command and Command R

  • Meta Llama

  • Mistral

For non-streaming InvokeModel responses, the instrumentation reads botocore.response.StreamingBody only to parse supported JSON response shapes, then replaces the response body with a fresh stream so application code can still read it.

Telemetry Details

The instrumentation sets:

  • gen_ai.system = aws.bedrock

  • gen_ai.framework = boto3

  • gen_ai.request.model from modelId

  • gen_ai.provider.name = aws.bedrock

  • request params such as temperature, top-p, max tokens, and stop sequences

  • response ID, response model, finish reasons, and token usage when available

  • gen_ai.request.stream and gen_ai.response.time_to_first_chunk for streaming calls

Requirements

  • Python >= 3.10

  • boto3 >= 1.34.0

  • splunk-otel-util-genai >= 0.1.9

Metadata

Release files for splunk-otel-instrumentation-bedrock 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for splunk-otel-instrumentation-bedrock 0.2.0
File Size Uploaded
splunk_otel_instrumentation_bedrock-0.2.0.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for splunk-otel-instrumentation-bedrock 0.2.0
File Interpreter ABI Platform
splunk_otel_instrumentation_bedrock-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.3 kB

Release files / splunk_otel_instrumentation_bedrock-0.2.0.tar.gz

Download URL splunk_otel_instrumentation_bedrock-0.2.0.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
35495bf8e70d4abb9caecef7efefeeb2e922eb1e54f0b01142c67660b5d00481
BLAKE2b-256 checksum
How to use checksums
b5c4513bf4c12d8d6f7a4b560137b182b1765188206178c17ccfa826509efa02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.17.1 {"ci":true,"cpu":"x86_64","distro":{"id":"trixie","libc":{"lib":"glibc","version":"2.41"},"name":"Debian GNU/Linux","version":"13"},"implementation":{"name":"CPython","version":"3.11.15"},"installer":{"name":"hatch","version":"1.17.1"},"openssl_version":"OpenSSL 3.5.6 7 Apr 2026","python":"3.11.15","system":{"name":"Linux","release":"5.15.0-1084-aws"}} HTTPX2/2.5.0

Release files / splunk_otel_instrumentation_bedrock-0.2.0-py3-none-any.whl

Download URL splunk_otel_instrumentation_bedrock-0.2.0-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d067eb121937854eb6b7807a690ff2fd358bf1130e2f7778949542ee5ffaf8f
BLAKE2b-256 checksum
How to use checksums
e3a23b478fd8db86cd8738491751be3ef12e5c895c7e402d78f2a28c6f6530e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.17.1 {"ci":true,"cpu":"x86_64","distro":{"id":"trixie","libc":{"lib":"glibc","version":"2.41"},"name":"Debian GNU/Linux","version":"13"},"implementation":{"name":"CPython","version":"3.11.15"},"installer":{"name":"hatch","version":"1.17.1"},"openssl_version":"OpenSSL 3.5.6 7 Apr 2026","python":"3.11.15","system":{"name":"Linux","release":"5.15.0-1084-aws"}} HTTPX2/2.5.0

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page