AWS Bedrock
Learn how to integrate AWS Bedrock with HoneyHive
Comprehensive Guide to Tracing AWS Bedrock with HoneyHive
AWS Bedrock gives you access to powerful foundation models (FMs) from Amazon and leading AI companies. This guide demonstrates how to implement tracing with HoneyHive to monitor and evaluate your AWS Bedrock applications.
Introduction to Tracing Types
HoneyHive provides four primary types of traces that work together to give you comprehensive visibility into your AWS Bedrock applications:
1. Model Invocation Traces
Model invocation traces capture each interaction with an AWS Bedrock model, recording:
- Input prompts and parameters
- Output responses
- Latency and token usage metrics
- Error information (if any occurs)
- Model-specific parameters
In our cookbook examples, model invocation traces are automatically captured when you make AWS Bedrock API calls like invoke_model
and converse
.
2. Function/Span Traces
Function traces (or spans) track the execution of specific functions in your code:
- Function inputs and outputs
- Execution duration
- Parent-child relationships between functions
- Custom metrics you define
The @trace
decorator is used to create function traces, as shown in all examples in our cookbook.
3. Session Traces
Session traces represent an entire user interaction or workflow:
- Group all related model invocations and function traces
- Maintain contextual information across multiple operations
- Provide a complete picture of a user journey or request
Sessions are created when you initialize the HoneyHive tracer at the beginning of your application.
4. Custom Event Traces
Custom event traces let you track specific events or add metrics to any trace:
- Business-specific metrics
- User feedback events
- Custom application states
- Performance metrics
Quickstart Guide
Installation
First, install the required dependencies:
The requirements.txt file includes:
Configuration
Create a .env
file based on the .env.example template:
Basic Usage Pattern
The basic pattern for tracing AWS Bedrock with HoneyHive follows these steps:
- Initialize the HoneyHive tracer
- Decorate functions with
@trace
- Make AWS Bedrock API calls
- Optionally add custom metrics
- Traces are automatically sent to HoneyHive
Detailed Examples
Listing Bedrock Models with Tracing
The bedrock_list_models.py example demonstrates:
- Initializing the HoneyHive tracer
- Using the
@trace
decorator for function tracing - Making AWS Bedrock API calls to list available foundation models
Key code sections:
Text Generation with InvokeModel API
The bedrock_invoke_model.py example shows:
- Tracing text generation with the InvokeModel API
- Structured error handling with tracing
- Parameter configuration for model invocation
Key code sections:
Conversation Tracing with Converse API
The bedrock_converse.py example demonstrates:
- Tracing multi-turn conversations
- Using the more advanced Converse API
- Maintaining conversation context across turns
Key code sections:
Conclusion
The AWS Bedrock + HoneyHive cookbook demonstrates how to implement comprehensive tracing for your AWS Bedrock applications. By following the patterns in these examples, you can gain visibility into your model performance, track user interactions, and gather metrics to improve your AI applications.
For more information:
- Visit the HoneyHive Documentation
- Check the AWS Bedrock Documentation
Was this page helpful?