Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down