documentation.suse.com / Monitoring SUSE AI with OpenTelemetry and SUSE Observability / Instrument applications with OpenLIT SDK

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.

Tip
Tip

For the full list of configuration options for OpenLIT SDKs, check the upstream documentation.

Procedure B1: Instrumenting using Python OpenLIT SDK
  1. Open terminal and add a OpenLIT dependency.

    > pip install openlit
  2. 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")
  3. 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?',
      },
    ])
Documentation survey