Skip to main content

OpenTelemetry instrumentation for Bedrock

Project description

Bedrock OpenTelemetry Integration

Overview

This integration provides support for using OpenTelemetry with the Bedrock framework. It enables tracing and monitoring of applications built with Bedrock.

Installation

  1. Install traceAI Bedrock
pip install traceAI-bedrock
  1. Install boto3
pip install boto3

Set Environment Variables

Set up your environment variables to authenticate with FutureAGI.

import os

os.environ["AWS_ACCESS_KEY_ID"] = AWS_ACCESS_KEY_ID
os.environ["AWS_SECRET_ACCESS_KEY"] = AWS_SECRET_ACCESS_KEY
os.environ["FI_API_KEY"] = FI_API_KEY
os.environ["FI_SECRET_KEY"] = FI_SECRET_KEY

Quickstart

Register Tracer Provider

Set up the trace provider to establish the observability pipeline. The trace provider:

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="bedrock_app"
)

Configure Bedrock Instrumentation

Instrument the Bedrock client to enable telemetry collection. This step ensures that all interactions with the Bedrock SDK are tracked and monitored.

from traceai_bedrock import BedrockInstrumentor

BedrockInstrumentor().instrument(tracer_provider=trace_provider)

Create Bedrock Components

Set up your Bedrock client with built-in observability.

def converse_with_claude():
    system_prompt = [{"text": "You are an expert at creating music playlists"}]
    messages = [
        {
            "role": "user",
            "content": [{"text": "Hello, how are you?"}, {"text": "What's your name?"}],
        }
    ]
    inference_config = {"maxTokens": 1024, "temperature": 0.0}

    try:
        response = client.converse(
            modelId="model_id",
            system=system_prompt,
            messages=messages,
            inferenceConfig=inference_config,
        )
        out = response["output"]["message"]
        messages.append(out)
        print(out)
    except Exception as e:
        print(f"Error: {str(e)}")

if __name__ == "__main__":
    converse_with_claude()

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

traceai_bedrock-0.1.5.tar.gz (13.1 kB view details)

Uploaded Source

Built Distributions

traceai_bedrock-0.1.5-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

traceai_bedrock-0.1.5-1-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file traceai_bedrock-0.1.5.tar.gz.

File metadata

  • Download URL: traceai_bedrock-0.1.5.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_bedrock-0.1.5.tar.gz
Algorithm Hash digest
SHA256 49cc65823815776f815c89e7c9ae71d01f4d01bfd7d0aea4e3a945f7c30dfc16
MD5 98bc4609a91365483272a5a40dc687af
BLAKE2b-256 59b25e365270955b6dc6ad4ce0c882f626cf8ebaf372045c30d0072e4c7ade34

See more details on using hashes here.

File details

Details for the file traceai_bedrock-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: traceai_bedrock-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_bedrock-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b8efafdb6502ec59abcc04c166c9f089f727cc3bc31e683d1be3afd3c5110747
MD5 53bc4605ddd043e80bf7a9f9e3283948
BLAKE2b-256 a0f7dafc736ad7f4c3e894d33d08dade4d3ecdde3463629ce06963fe5808c2ef

See more details on using hashes here.

File details

Details for the file traceai_bedrock-0.1.5-1-py3-none-any.whl.

File metadata

  • Download URL: traceai_bedrock-0.1.5-1-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_bedrock-0.1.5-1-py3-none-any.whl
Algorithm Hash digest
SHA256 a78857e55bdc14f9a892d3d29941f9b52416b9e2185a4e2e0e25440a85fa201a
MD5 75e38bab1628a85aa22b25cad72f95d4
BLAKE2b-256 4d453295f42ecb3183f2f3f0a9adc022ba63bde165e037740ab84380f6e08b9e

See more details on using hashes here.

Supported by

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