diff --git a/litestar/contrib/opentelemetry/plugin.py b/litestar/contrib/opentelemetry/plugin.py index 39c84afc46..6d5f34677c 100644 --- a/litestar/contrib/opentelemetry/plugin.py +++ b/litestar/contrib/opentelemetry/plugin.py @@ -42,7 +42,8 @@ def _pop_otel_middleware(middlewares: list[Middleware]) -> tuple[list[Middleware for middleware in middlewares: if ( isinstance(middleware, DefineMiddleware) - and middleware.middleware is OpenTelemetryInstrumentationMiddleware + and isinstance(middleware.middleware, type) + and issubclass(middleware.middleware, OpenTelemetryInstrumentationMiddleware) ): otel_middleware = middleware else: