diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a0faa56ae..8c51817656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -112,6 +112,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#4078](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4171)) - `opentelemetry-instrumentation-aiohttp-server`: fix HTTP error inconsistencies ([#4175](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4175)) +- `opentelemetry-instrumentation-falcon`: Refactor `_handle_exception` to remove pylint disables + ([#4207](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4207)) ### Breaking changes 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 bfc82b7a17..09429f8bb5 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py @@ -328,33 +328,22 @@ def __del__(self): if self in _InstrumentedFalconAPI._instrumented_falcon_apps: _InstrumentedFalconAPI._instrumented_falcon_apps.remove(self) - def _handle_exception(self, arg1, arg2, arg3, arg4): # pylint: disable=C0103,W0237 - # Falcon 3 does not execute middleware within the context of the exception - # so we capture the exception here and save it into the env dict - - # Translation layer for handling the changed arg position of "ex" in Falcon > 2 vs - # Falcon < 2 + def _handle_exception(self, *args): + # Falcon 3 does not execute middleware within the context + # of the exception so we capture the exception here and + # save it into the env dict if not self._is_instrumented_by_opentelemetry: - return super()._handle_exception(arg1, arg2, arg3, arg4) + return super()._handle_exception(*args) if _falcon_version == 1: - ex = arg1 - req = arg2 - resp = arg3 - params = arg4 + _, req, _, _ = args # ex, req, resp, params else: - req = arg1 - resp = arg2 - ex = arg3 - params = arg4 + req, _, _, _ = args # req, resp, ex, params _, exc, _ = exc_info() req.env[_ENVIRON_EXC] = exc - if _falcon_version == 1: - return super()._handle_exception(ex, req, resp, params) # pylint: disable=W1114 - - return super()._handle_exception(req, resp, ex, params) + return super()._handle_exception(*args) def __call__(self, env, start_response): # pylint: disable=E1101