Skip to content

[Feature]: integrate with default opentelemetry exporter configured by opentelemetry-instrument #9901

@codefromthecrypt

Description

@codefromthecrypt

The Feature

I would like to use the OpenTelemetry callback without litellm specific customization. For example, I would like to use the "zero code approach" of otel and prefix my python application with opentelemetry-instrument. Then I can use normal ENV variables like OTEL_EXPORTER_OTLP_ENDPOINT and not have to explicitly use custom protocol keys like otlp_http.

So, I would like to replace this code:

otlp_endpoint = os.getenv("OTEL_EXPORTER_OTLP_ENDPOINT") + "/v1/traces"
otel_config = OpenTelemetryConfig(exporter="otlp_http", endpoint=otlp_endpoint)
litellm.callbacks = [OpenTelemetry(otel_config)]

With simply

litellm.callbacks = [OpenTelemetry()]

And this requires the OpenTelemetry callback to look if there is already a TracerProvider and SpanExporter available. In this case do not use litellm's custom way to initialize them, just use them.

Motivation, pitch

LiteLLM is increasingly used as an internal library, and it breaks abstraction to have to consider custom configuration from outer libraries like ADK or crewAI. Even if there is a need to explicitly register the callback, it is easier if the ENV variables are standard like otel defines, as it reduces the knowledge burden.

Are you a ML Ops Team?

No

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions