Spring AI Integration via OpenTelemetry
Spring AI is a framework designed to simplify the integration of AI and machine learning capabilities into Spring applications. It provides a familiar Spring-based programming model for working with AI models, vector stores, and AI-powered features, making it easier to build intelligent applications within the Spring ecosystem.
Spring AI’s primary advantage is its seamless integration with the Spring framework, allowing developers to leverage Spring’s dependency injection, configuration management, and testing capabilities while building AI-powered applications.
Getting started
To use the Spring AI integration with Opik, you will need to have Spring AI and the required OpenTelemetry packages installed:
Environment configuration
Configure your environment variables based on your Opik deployment:
Opik Cloud
Enterprise deployment
Self-hosted instance
If you are using Opik Cloud, you will need to set the following environment variables:
To log the traces to a specific project, you can add the
projectName
parameter to the OTEL_EXPORTER_OTLP_HEADERS
environment variable:
You can also update the Comet-Workspace
parameter to a different
value if you would like to log the data to a different workspace.
Using Opik with Spring AI
Set up OpenTelemetry instrumentation for Spring AI in your application.properties
:
Your Spring AI code will now automatically send traces to Opik:
Further improvements
If you have any questions or suggestions for improving the Spring AI integration, please open an issue on our GitHub repository.