Skip to content

Commit 707f830

Browse files
feat(integrations): add AWS Bedrock tracer
1 parent fdea67e commit 707f830

File tree

2 files changed

+541
-0
lines changed

2 files changed

+541
-0
lines changed

src/openlayer/lib/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"trace_groq",
1010
"trace_async_openai",
1111
"trace_async",
12+
"trace_bedrock",
1213
]
1314

1415
# ---------------------------------- Tracing --------------------------------- #
@@ -84,3 +85,26 @@ def trace_groq(client):
8485
if not isinstance(client, groq.Groq):
8586
raise ValueError("Invalid client. Please provide a Groq client.")
8687
return groq_tracer.trace_groq(client)
88+
89+
90+
def trace_bedrock(client):
91+
"""Trace AWS Bedrock model invocations."""
92+
# pylint: disable=import-outside-toplevel
93+
try:
94+
import boto3
95+
except ImportError:
96+
raise ImportError(
97+
"boto3 is required for Bedrock tracing. Install with: pip install boto3"
98+
)
99+
100+
from .integrations import bedrock_tracer
101+
102+
# Check if it's a boto3 client for bedrock-runtime service
103+
if (
104+
not hasattr(client, "_service_model")
105+
or client._service_model.service_name != "bedrock-runtime"
106+
):
107+
raise ValueError(
108+
"Invalid client. Please provide a boto3 bedrock-runtime client."
109+
)
110+
return bedrock_tracer.trace_bedrock(client)

0 commit comments

Comments
 (0)