feat(otel): move away from contrib module#4691
Merged
Merged
Conversation
cofin
requested review from
a team,
JacobCoffee and
provinzkraut
as code owners
April 13, 2026 15:47
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4691 +/- ##
==========================================
+ Coverage 67.40% 67.42% +0.01%
==========================================
Files 292 292
Lines 15013 15022 +9
Branches 1686 1686
==========================================
+ Hits 10119 10128 +9
Misses 4758 4758
Partials 136 136 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cofin
force-pushed
the
feat/otel-plugin
branch
2 times, most recently
from
April 13, 2026 20:48
14ee32a to
bb0d601
Compare
JacobCoffee
reviewed
Apr 19, 2026
Member
|
This seems to be targeting the wrong branch. It's deprecating things to be removed in |
cofin
force-pushed
the
feat/otel-plugin
branch
4 times, most recently
from
April 26, 2026 16:05
1df4b4a to
2aa4a1a
Compare
…org#4466, add upstream parity
Member
Author
|
@provinzkraut deprecation notices removed and will be bundled in a separate PR. |
Member
|
@cofin if this is now intentionally targeting |
Member
Author
|
@provinzkraut merge conflicts resolved and changelog entry added. |
provinzkraut
approved these changes
May 9, 2026
This was referenced May 9, 2026
cofin
added a commit
that referenced
this pull request
May 11, 2026
…ns.minijinja (#4760) Moves the MiniJinja template engine integration from `litestar.contrib.minijinja` to `litestar.plugins.minijinja`, and removes the contrib path on `main`. A follow-up PR onto `v2` will add a deprecation shim covering both public and private symbols. Same shape as the OTel split (#4691 + #4759) and the repository split (#4735 + #4758). `litestar/plugins/flash.py` lazily imports the private `_transform_state` from MiniJinja, so any deprecation shim has to forward private symbols. That diagnosis came from @xronocode's audit in #4754; this PR preserves it by migrating flash.py before deleting contrib, so every intermediate commit keeps the dependency graph valid. Salvages the contrib tests into `tests/unit/test_plugins/test_minijinja.py` (98% coverage), migrates every internal call site, and adds `docs/reference/plugins/minijinja.rst`. Closes #4718. Co-authored-by: xronocode <myevdokimov@gmail.com>
cofin
added a commit
that referenced
this pull request
May 11, 2026
…4764) Moves the Mako template engine integration from `litestar.contrib.mako` to `litestar.plugins.mako`, and removes the contrib path on `main`. A follow-up PR onto `v2` will add a deprecation shim, giving 2.x users a migration window. Same shape as the OTel split (#4691 + #4759) and the repository split (#4735 + #4758). Implementation reference: PR #4753 by @xronocode. Every commit carries a co-author trailer. Salvages the contrib tests into `tests/unit/test_plugins/test_mako.py`, migrates every internal call site (csrf middleware, flash, template suite), and adds `docs/reference/plugins/mako.rst`. Closes #4717. Co-authored-by: xronocode <myevdokimov@gmail.com>
cofin
added a commit
that referenced
this pull request
May 13, 2026
…#4762) Moves the Jinja2 template engine integration from `litestar.contrib.jinja` to `litestar.plugins.jinja`, and removes the contrib path on `main`. A follow-up PR onto `v2` will add a deprecation shim, giving 2.x users a migration window. Same shape as the OTel split (#4691 + #4759) and the repository split (#4735 + #4758). Implementation reference: PR #4752 by @xronocode. Every commit carries a co-author trailer. Salvages the contrib tests into `tests/unit/test_plugins/test_jinja.py`, migrates every internal call site (csrf middleware, flash, template suite, htmx examples), and adds `docs/reference/plugins/jinja.rst`. Closes #4716. Co-authored-by: xronocode <myevdokimov@gmail.com>
cofin
added a commit
that referenced
this pull request
May 14, 2026
…ib namespace (#4759) This moves the OpenTelemetry integration to `litestar.plugins.opentelemetry` and turns `litestar.contrib.opentelemetry` into a deprecation shim. The same move landed on main as #4691; this is the v2 side, so 2.x users get both a real migration target on their current version and a `DeprecationWarning` pointing them at it. They can update imports while still on 2.x and upgrade cleanly to 3.0.0. Three symbols are covered: `OpenTelemetryConfig`, `OpenTelemetryInstrumentationMiddleware`, and `OpenTelemetryPlugin`. The contrib location — which was the real implementation on v2 until now — becomes a thin PEP 562 `__getattr__` shim that re-exports from the plugin namespace. ```python # before from litestar.contrib.opentelemetry import OpenTelemetryPlugin # after from litestar.plugins.opentelemetry import OpenTelemetryPlugin ``` Two upstream bug fixes ride along with the move: - A `route_handler is None` guard in the middleware helper, fixing a `KeyError` when the OTel middleware runs as the outermost layer before route resolution (#4468) - Corrected client request/response hook signatures — three params instead of two, matching `opentelemetry-instrumentation-asgi` (#4466) The config also exposes `tracer` and `http_capture_headers_*` fields that #4691 added on main. Tests split cleanly: `tests/unit/test_contrib/test_opentelemetry.py` is now the deprecation suite (each access fires `DeprecationWarning` and resolves to the same object as the plugin namespace), and `tests/unit/test_plugins/test_opentelemetry.py` carries the behavior tests for the new namespace. Deprecated in 2.22.0, removed in 3.0.0. Changelog entry added under the new 2.22.0 block.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the OpenTelemetry plugin from
litestar.contrib.opentelemetryto its permanent home atlitestar.plugins.opentelemetry. Thecontribdirectory is removed entirely on this branch — there's no shim here.A few things ride along:
scope["route_handler"]access inlitestar/middleware/_utils.pyso the OTel middleware doesn'tKeyErrorwhen it runs as the outermost ASGI layer (which it does in practice, since it sits before route resolution).opentelemetry-instrumentation-asgi(3 parameters, not 2), so user-supplied hooks actually type-check.tracerandhttp_capture_headers_*config params that were missing fromOpenTelemetryConfigbut supported by the underlying instrumentation library.The deprecation shim at
litestar.contrib.opentelemetry(with itsDeprecationWarning) has been split out to a follow-up PR targetingv2— that's where 2.x users actually need the migration window before 3.0 GA. This PR is purely the move plus the bug fixes and parity work.Fixes #4468
Fixes #4466
📚 Documentation preview 📚: https://litestar-org.github.io/litestar-docs-preview/4691