Skip to content

ref(litellm): migrate litellm wrapper to integrations API#160

Open
Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits intomainfrom
abhi-feat-litellm-integrations-api-migration
Open

ref(litellm): migrate litellm wrapper to integrations API#160
Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits intomainfrom
abhi-feat-litellm-integrations-api-migration

Conversation

@AbhiPrasad
Copy link
Copy Markdown
Member

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Mar 26, 2026

ref #116

Convert the LiteLLM instrumentation from the legacy wrappers pattern to the new integrations API introduced in #118.

Move the LiteLLM tracing implementation from wrappers/litellm.py into the integrations API under integrations/litellm/. This replaces the manual LiteLLMWrapper class approach with FunctionWrapperPatcher subclasses that use wrapt's wrap_function_wrapper for idempotent monkey-patching.

Key changes:

  • Add integrations/litellm/ with tracing.py, patchers.py, and integration.py following the standard integrations API pattern
  • Add wrap_litellm() helper that instruments a specific litellm module object using the patchers, complementing the existing patch_litellm() which patches the globally-imported module
  • Consolidate patcher list into _ALL_PATCHERS, shared by both LiteLLMIntegration.patchers and wrap_litellm()
  • Reduce wrappers/litellm.py to compatibility re-exports
  • Move tests and cassettes to integrations/litellm/
  • Add cassettes_dir parameter to autoinstrument_test_context

Move the LiteLLM tracing implementation from wrappers/litellm.py into
the integrations API under integrations/litellm/. This replaces the
manual LiteLLMWrapper class approach with FunctionWrapperPatcher
subclasses that use wrapt's wrap_function_wrapper for idempotent
monkey-patching.

Key changes:
- Add integrations/litellm/ with tracing.py, patchers.py, and
  integration.py following the standard integrations API pattern
- Add wrap_litellm() helper that instruments a specific litellm module
  object using the patchers, complementing the existing patch_litellm()
  which patches the globally-imported module
- Consolidate patcher list into _ALL_PATCHERS, shared by both
  LiteLLMIntegration.patchers and wrap_litellm()
- Reduce wrappers/litellm.py to compatibility re-exports
- Move tests and cassettes to integrations/litellm/
- Add cassettes_dir parameter to autoinstrument_test_context
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) changed the title feat(litellm): migrate litellm wrapper to integrations API ref(litellm): migrate litellm wrapper to integrations API Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant