Overview
Integration with Opik
As of today, Opik
does not provide a Ruby SDK. However, you can use the Opik OpenTelemetry integration to send telemetry data to Opik.
Opik Configuration
You can configure your application to use OpenTelemetry SDK by setting up the following dependencies:
Next, you need to set up the OpenTelemetry SDK and configure it to use the Opik as the traces backend.
Usage
Once configured, you can start using the OpenTelemetry SDK in your application. The following example demonstrates how to create a simple trace and span:
It’s important to note that OpenTelemetry (otel) auto-instrumentations don’t automatically align with Opik’s schema, so you may need to manually set certain attributes, like the output
attribute in the example above.
Opik supports mapping of attributes to Opik traces, for the following libraries:
python/OpenInference
python/Pydantic
python/GenAI
In the future we may add more integrations to Opik. If you have any suggestions on what else could be integrated into Opik, please let us know!
If your application is a short-lived process, you may need to call OpenTelemetry.tracer_provider.force_flush(timeout: <timeout>)
or similar method at the end of your application to ensure all telemetry data is flushed before exiting.
Conclusion
This guide provided an overview of how to integrate Opik with the OpenTelemetry SDK in Ruby. By following the steps outlined above, you can easily set up your application to send telemetry data to Opik for monitoring and analysis.
Feel free to reach out to us if you have any questions or issues with the integration, via the GitHub repository, or join our Slack channel.