Skip to main content

OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications, facilitating the integration of observability into your GenAI-driven projects

Project description

OpenLIT Logo

OpenTelemetry Auto-Instrumentation for GenAI & LLM Applications

Documentation | Quickstart | Python SDK

OpenLIT License Downloads GitHub Last Commit GitHub Contributors

Slack X

OpenLIT Python SDK is an OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications, facilitating the integration of observability into your GenAI-driven projects. Designed with simplicity and efficiency, OpenLIT offers the ability to embed observability into your GenAI-driven projects effortlessly using just a single line of code.

Whether you're directly using LLM Libraries like OpenAI, Anthropic or building complex RAG Agents using Langchain, OpenLIT seamlessly integrates observability into your applications, ensuring enhanced performance and reliability across diverse scenarios.

This project adheres to the Semantic Conventions proposed by the OpenTelemetry community. You can check out the current definitions here.

What can be Auto Instrumented?

LLMs

Vector DBs

Frameworks

Supported Destinations

💿 Installation

pip install openlit

🚀 Getting Started

Step 1: Install OpenLIT SDK

pip install openlit

Step 2: Instrument your Application

Integrating the OpenLIT into LLM applications is straightforward. Start monitoring for your LLM Application with just one line of code:

import openlit

openlit.init()

By default, OpenLIT directs traces and metrics straight to your console. To forward telemetry data to an HTTP OTLP endpoint, such as the OpenTelemetry Collector, set the otlp_endpoint parameter with the desired endpoint. Alternatively, you can configure the endpoint by setting the OTEL_EXPORTER_OTLP_ENDPOINT environment variable as recommended in the OpenTelemetry documentation.

To send telemetry to OpenTelemetry backends requiring authentication, set the otlp_headers parameter with its desired value. Alternatively, you can configure the endpoint by setting the OTEL_EXPORTER_OTLP_HEADERS environment variable as recommended in the OpenTelemetry documentation.

Example

Here is how you can send telemetry from OpenLIT to Grafana Cloud

openlit.init(
  otlp_endpoint="https://otlp-gateway-prod-us-east-0.grafana.net/otlp", 
  otlp_headers="Authorization=Basic%20<base64 encoded Instance ID and API Token>"
)

Alternatively, You can also choose to set these values using OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS environment variables

openlit.init()
export OTEL_EXPORTER_OTLP_ENDPOINT = "https://otlp-gateway-prod-us-east-0.grafana.net/otlp"
export OTEL_EXPORTER_OTLP_HEADERS = "Authorization=Basic%20<base64 encoded Instance ID and API Token>"

Step 3: Visualize and Optimize!

With the LLM Observability data now being collected and sent to your chosen OpenTelemetry backend, the next step is to visualize and analyze this data to glean insights into your application's performance, behavior, and identify areas of improvement. Here is how you would use the data in Grafana, follow these detailed instructions to explore your LLM application's Telemetry data.

  • Select the Explore option from Grafana's sidebar.
  • At the top, ensure the correct Tempo data source is selected from the dropdown menu.
  • Use the Query field to specify any particular traces you are interested in, or leave it empty to browse through all the available traces.
  • You can adjust the time range to focus on specific periods of interest.
  • Hit Run Query to fetch your trace data. You'll see a visual representation of your traces along with detailed information on particular spans when clicked.

Next Steps

  • Create Dashboards: Beyond just exploring traces, consider creating dashboards in Grafana to monitor key performance indicators (KPIs) and metrics over time. Dashboards can be customized with various panels to display graphs, logs, and single stats that are most relevant to your application's performance and usage patterns.
  • Set Alerts: Grafana also allows you to set up alerts based on specific thresholds. This feature can be invaluable in proactively managing your application's health by notifying you of potential issues before they impact users.
  • Iterate and Optimize: Use the insights gained from your observability data to make informed decisions on optimizing your LLM application. This might involve refining model parameters, adjusting scaling strategies, or identifying and resolving bottlenecks.

Configuration

Below is a detailed overview of the configuration options available, allowing you to adjust OpenLIT's behavior and functionality to align with your specific observability needs:

Argument Description Default Value Required
environment The deployment environment of the application. "default" Yes
application_name Identifies the name of your application. "default" Yes
tracer An instance of OpenTelemetry Tracer for tracing operations. None No
meter An OpenTelemetry Metrics instance for capturing metrics. None No
otlp_endpoint Specifies the OTLP endpoint for transmitting telemetry data. None No
otlp_headers Defines headers for the OTLP exporter, useful for backends requiring authentication. None No
disable_batch A flag to disable batch span processing, favoring immediate dispatch. False No
trace_content Enables tracing of content for deeper insights. True No
disabled_instrumentors List of instrumentors to disable. Choices: ["openai", "anthropic", "langchain", "cohere", "mistral", "transformers", "chroma", "pinecone"]. None No
disable_metrics If set, disables the collection of metrics. False No

🌱 Contributing

Whether it's big or small, we love contributions 💚. Check out our Contribution guide to get started

Unsure where to start? Here are a few ways to get involved:

  • Join our Slack channel to discuss ideas, share feedback, and connect with both our team and the wider OpenLIT community.

Your input helps us grow and improve, and we're here to support you every step of the way.

💚 Community & Support

Connect with the OpenLIT community and maintainers for support, discussions, and updates:

  • 🌟 If you like it, Leave a star on our GitHub
  • 🌍 Join our Slack Community for live interactions and questions.
  • 🐞 Report bugs on our GitHub Issues to help us improve OpenLIT.
  • 𝕏 Follow us on X for the latest updates and news.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openlit-1.3.0.tar.gz (54.0 kB view hashes)

Uploaded Source

Built Distribution

openlit-1.3.0-py3-none-any.whl (84.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page