This project demonstrates how to use the AWS Bedrock Runtime to invoke a model with response streaming and send trace spans to Datadog.
- Java 11 or higher
- Maven
- AWS credentials configured
- Datadog API key
-
Clone the repository:
git clone https://github.com/yourusername/dd_java_bedrock_demo.git cd dd_java_bedrock_demo
-
Create a
.env
file in the root directory and add your Datadog API key:touch .env echo "DD_API_KEY=your_datadog_api_key" >> .env
-
Build the project using Maven:
mvn clean install
To run the application, execute the following command:
mvn exec:java -Dexec.mainClass="com.datadoghq.InvokeModelWithResponseStream"
- The application will prompt you to enter a message.
- Enter your message and press Enter.
- The application will invoke the model with the provided message and print the response.
- The application will also send trace spans to Datadog.
To exit the application, type exit
and press Enter.
To run the tests, execute the following command:
mvn test
src/main/java/com/datadoghq/InvokeModelWithResponseStream.java
: Main class that handles invoking the model and sending trace spans.src/test/java/com/datadoghq/AppTest.java
: Test class for the application..gitignore
: Git ignore file.pom.xml
: Maven project file.