From 2d4e6c9ac775347e04ed04d4898f9ad6b0372503 Mon Sep 17 00:00:00 2001 From: mshebeko-twist <83533845+mshebeko-twist@users.noreply.github.com> Date: Wed, 19 Apr 2023 20:23:21 +0300 Subject: [PATCH] fix: None does not implement middleware when there are no middlewares (#1766) --- CHANGELOG.md | 3 ++- .../src/opentelemetry/instrumentation/falcon/__init__.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e69e2d091d..a4e787b8bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix `AttributeError` when AWS Lambda handler receives a list event ([#1738](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1738)) - +- Fix `None does not implement middleware` error when there are no middlewares registered + ([#1766](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1766)) ## Version 1.17.0/0.38b0 (2023-03-22) diff --git a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py index 33b9a13360..3a6a86e4fb 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py @@ -245,6 +245,9 @@ def __init__(self, *args, **kwargs): # inject trace middleware self._middlewares_list = kwargs.pop("middleware", []) + if self._middlewares_list is None: + self._middlewares_list = [] + tracer_provider = otel_opts.pop("tracer_provider", None) meter_provider = otel_opts.pop("meter_provider", None) if not isinstance(self._middlewares_list, (list, tuple)):