Skip to content

Add OpenTelemetry instrumentation for LiteLLM#88

Merged
Cirilla-zmh merged 8 commits intoalibaba:mainfrom
whoIam0987:mingzhi/litellm
Mar 10, 2026
Merged

Add OpenTelemetry instrumentation for LiteLLM#88
Cirilla-zmh merged 8 commits intoalibaba:mainfrom
whoIam0987:mingzhi/litellm

Conversation

@whoIam0987
Copy link
Contributor

@whoIam0987 whoIam0987 commented Dec 15, 2025

Description

Instrument Litellm with genai util.
Fixes #60 (issue)

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Modify releated unit tests.

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@CLAassistant
Copy link

CLAassistant commented Dec 15, 2025

CLA assistant check
All committers have signed the CLA.

@whoIam0987 whoIam0987 changed the title [WIP] Add OpenTelemetry instrumentation for LiteLLM Add OpenTelemetry instrumentation for LiteLLM Feb 5, 2026
@ralf0131 ralf0131 requested a review from Copilot February 5, 2026 13:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds OpenTelemetry instrumentation for the LiteLLM library, which provides a unified interface to 100+ LLM providers. The instrumentation captures telemetry data for LLM operations including completions, embeddings, streaming, tool calls, and retry mechanisms.

Changes:

  • Added new instrumentation package for LiteLLM with support for sync/async completion and embedding APIs
  • Implemented streaming response wrappers with proper span lifecycle management
  • Added comprehensive test suite covering various LiteLLM features including tool calls, retries, and error handling

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
__init__.py Main instrumentor class that wraps LiteLLM functions and manages telemetry handlers
_wrapper.py Completion wrappers for sync/async calls with streaming support
_embedding_wrapper.py Embedding operation wrappers for sync/async calls
_stream_wrapper.py Stream response wrappers handling chunk accumulation and finalization
_utils.py Utility functions for message conversion, provider parsing, and invocation creation
version.py, package.py Package metadata and dependency declarations
pyproject.toml Package configuration with build system and dependencies
README.rst Documentation for installation, configuration, and usage
test_*.py Comprehensive test suite covering completions, embeddings, streaming, tools, retries, and errors
test-requirements.txt Test dependency specifications

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@Cirilla-zmh Cirilla-zmh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Please address the remaining comments so we can move this PR forward.

Copy link
Collaborator

@Cirilla-zmh Cirilla-zmh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments should be resolved.

2 This LISENSE file has been removed;
3 The CHANGELOG.md file has been added;
4 This SUPPRESS_LLM_SDK_KEY and releted code have been removed;
5 Metric is not supported.
@Cirilla-zmh Cirilla-zmh added enhancement New feature or request instrumentaion The instrumentation label represents issues related to instrumentation. genai The genai label represents issues related to generative AI. labels Mar 6, 2026
Change-Id: I8f94218ade0d45445db338f241ae2d432bb30ef7
Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I5f4ff4d48fbafd665e9f8b6e6049e870ff3c102b
Co-developed-by: Cursor <noreply@cursor.com>
@Cirilla-zmh Cirilla-zmh self-requested a review March 10, 2026 04:14
Copy link
Collaborator

@Cirilla-zmh Cirilla-zmh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Cirilla-zmh Cirilla-zmh merged commit 03d21d7 into alibaba:main Mar 10, 2026
75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request genai The genai label represents issues related to generative AI. instrumentaion The instrumentation label represents issues related to instrumentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add instrumentation for LiteLLM

6 participants