Skip to main content

Respan instrumentation plugin for AWS Bedrock Runtime

Project description

respan-instrumentation-aws-bedrock

Respan instrumentation plugin for AWS Bedrock Runtime calls made through boto3.

Installation

pip install respan-ai respan-instrumentation-aws-bedrock boto3

Usage

import json

import boto3
from respan import Respan
from respan_instrumentation_aws_bedrock import AWSBedrockInstrumentor

respan = Respan(instrumentations=[AWSBedrockInstrumentor()])
client = boto3.client("bedrock-runtime", region_name="us-east-1")

response = client.invoke_model(
    modelId="anthropic.claude-3-5-haiku-20241022-v1:0",
    body=json.dumps({
        "anthropic_version": "bedrock-2023-05-31",
        "max_tokens": 256,
        "messages": [{"role": "user", "content": "Say hello."}],
    }),
    contentType="application/json",
    accept="application/json",
)

body = json.loads(response["body"].read())
print(body["content"][0]["text"])
respan.flush()

The instrumentor patches botocore.client.BaseClient._make_api_call and only emits spans for Bedrock Runtime operations. It currently normalizes InvokeModel, InvokeModelWithResponseStream, Converse, and ConverseStream into canonical Respan chat spans.

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

respan_instrumentation_aws_bedrock-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file respan_instrumentation_aws_bedrock-0.1.0.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_aws_bedrock-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ec0518017105e098b36d1d0d6bc5655599ce3fbb44a5b873eb3bc99696b45f19
MD5 dc0c97dd98335d4bcfc063a928e2b824
BLAKE2b-256 81c053236d6789f26f35f87b61c682f11c2b31b7965062319ed8a447fd23efde

See more details on using hashes here.

File details

Details for the file respan_instrumentation_aws_bedrock-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_instrumentation_aws_bedrock-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2c93c2d2e658baadc8f79c27c072ba47705f78fb99134e18dd7a117529f5c5d
MD5 7a137103425ff0346008c6138b7aa1d8
BLAKE2b-256 67a16fc0b0cf75015f4d679d44c0b50fd625bc0866a2090917430926dffe6372

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