Skip to main content

OpenTelemetry Bedrock AgentCore instrumentation

Project description

pypi

This package provides OpenTelemetry instrumentation for AWS Bedrock AgentCore, the runtime framework for building agentic applications with AWS Bedrock. It leverages Splunk distribution of opentelemetry-util-genai for producing telemetry in semantic convention. Core concepts, high-level usage and configuration

Status: Alpha (APIs and produced telemetry are subject to change).

Installation

pip install splunk-otel-instrumentation-bedrock-agentcore

Quick Start

Manual Instrumentation (development/debugging)

from bedrock_agentcore import BedrockAgentCoreApp
from opentelemetry.instrumentation.bedrock_agentcore import (
    BedrockAgentCoreInstrumentor,
)

# Manual instrumentation, easy to debug in your IDE
BedrockAgentCoreInstrumentor().instrument()

app = BedrockAgentCoreApp()

@app.entrypoint
def handler(event):
    return {"status": "success", "event": event}

Zero-code Instrumentation

In zero-code instrumentation mode, ensure you install opentelemetry-distribution and run your app with the OpenTelemetry Bedrock AgentCore instrumentor enabled:

.. code-block:: bash

opentelemetry-instrument python your_bedrock_agentcore_app.py

from bedrock_agentcore import BedrockAgentCoreApp

app = BedrockAgentCoreApp()

@app.entrypoint
def handler(event):
    return {"status": "success", "event": event}

What Gets Instrumented

This instrumentation captures:

  • BedrockAgentCoreApp -> Mapped to Workflow spans

  • MemoryClient.retrieve_memories -> Mapped to RetrievalInvocation spans

  • MemoryClient operations -> Mapped to ToolCall spans

  • CodeInterpreter operations -> Mapped to ToolCall spans

  • BrowserClient operations -> Mapped to ToolCall spans

All spans are properly nested with correct parent-child relationships and include rich attributes about the operation.

Testing Reference

For a detailed implementation map, configuration matrix, wrapped SDK method inventory, span attribute assertions, and suggested test cases, see docs/testing-reference.md.

Compositional Instrumentation

This instrumentation focuses on Bedrock AgentCore runtime operations. For complete observability, combine it with provider-specific or framework-specific instrumentation.

AgentCore + Bedrock

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

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

Adds Bedrock API call spans with AWS-specific attributes and metrics.

AgentCore + Bedrock + Strands

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

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

Adds agent orchestration, runtime operations, and Bedrock model call telemetry.

Configuration

Environment Variables

# Capture request/response content (disabled by default)
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true

# Content capture mode
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT_MODE=SPAN_AND_EVENT

# Select GenAI emitters
export OTEL_INSTRUMENTATION_GENAI_EMITTERS=span_metric_event

Instrumentation Options

from opentelemetry.instrumentation.bedrock_agentcore import (
    BedrockAgentCoreInstrumentor,
)

# Basic instrumentation
BedrockAgentCoreInstrumentor().instrument()

# With custom providers
BedrockAgentCoreInstrumentor().instrument(
    tracer_provider=my_tracer_provider,
    meter_provider=my_meter_provider,
    logger_provider=my_logger_provider,
)

# Uninstrumentation
BedrockAgentCoreInstrumentor().uninstrument()

Requirements

  • Python >= 3.10

  • bedrock-agentcore >= 1.0.0

  • OpenTelemetry API >= 1.38

  • splunk-otel-util-genai >= 0.1.9

Trace Hierarchy Example

BedrockAgentCoreApp.entrypoint (Workflow)
+-- Memory: retrieve_memories (RetrievalInvocation)
+-- CodeInterpreter: execute_code (ToolCall)
+-- Browser: take_control (ToolCall)

Each span includes rich attributes:

  • gen_ai.system = “bedrock-agentcore”

  • gen_ai.operation.name = “invoke_workflow” | “execute_tool” | “retrieval”

  • Retrieval span names include the memory provider, for example retrieval bedrock-agentcore-memory

  • Framework-specific attributes, such as memory IDs, code interpreter session IDs, browser session IDs, and operation metadata

Examples

The examples/manual directory contains a working example that exercises BedrockAgentCoreApp, MemoryClient, CodeInterpreter, and BrowserClient instrumentation with OTLP export.

cd examples/manual
pip install -r requirements.txt
pip install -e ../../[instruments]

export AWS_DEFAULT_REGION=us-west-2
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
python main.py

Testing

Run the package tests from the repository root or this directory:

pytest instrumentation-genai/opentelemetry-instrumentation-bedrock-agentcore/tests

Contributing

Issues / PRs welcome in the main splunk-otel-python-contrib repository. This module is alpha: feedback on attribute coverage, performance, and Bedrock AgentCore surface expansion is especially helpful.

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file splunk_otel_instrumentation_bedrock_agentcore-0.3.0.tar.gz.

File metadata

  • Download URL: splunk_otel_instrumentation_bedrock_agentcore-0.3.0.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for splunk_otel_instrumentation_bedrock_agentcore-0.3.0.tar.gz
Algorithm Hash digest
SHA256 42f3a2e62e4b2f9d61be94fa3df46f0516620a76f0458f06ae2f2342fb0af391
MD5 5d058dc744ecf2592a27cab88554999f
BLAKE2b-256 16b38f7a8063e080d8fc4da7b6323055c0cb65ef2d1a8cff4f98c53e1e5b58c6

See more details on using hashes here.

File details

Details for the file splunk_otel_instrumentation_bedrock_agentcore-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: splunk_otel_instrumentation_bedrock_agentcore-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for splunk_otel_instrumentation_bedrock_agentcore-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0caef6d564cc86bcc0f5e89bba632dab187e20925b49bf02d5b1b881a5275c5
MD5 8e8deda5ba712f70eab6272012efb9bf
BLAKE2b-256 05edc7645cc575ab1b03481eb6d119d23b130a2bf3338344c721f9571af91f09

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page