Instrument applications with OpenLIT SDK
OpenLIT has a Python and a Typescript SDK available. The following procedures describe examples of instrumentation, one for each language.
Procedure B1: Instrumenting using Python OpenLIT SDK #
Open terminal and add a OpenLIT dependency.
>
pip install openlit
Import OpenLIT and initialize it in your code, usually in the main entrypoint. Remember to adjust the OpenTelemetry Protocol (OTLP) endpoint.
import openlit openlit.init(otlp_endpoint="http://otel-collector.observability.svc.cluster.local:4318")
With this code in place, you will start receiving telemetry data from the libraries currently supported by OpenLIT. You can test it with Ollama by following this example:
import ollama import openlit openlit.init() response = ollama.chat(model='gemma:2b', messages=[ { 'role': 'user', 'content': 'Why is the sky blue?', }, ])