diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b45d6e90e..45163e7889 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix bug in Urllib instrumentation - add status code to span attributes only if the status code is not None. ([#1430](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1430)) +- `opentelemetry-instrumentation-aiohttp-client` Allow overriding of status in response hook. + ([#1394](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1394)) - `opentelemetry-instrumentation-pymysql` Fix dbapi connection instrument wrapper has no _sock member. ([#1424](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1424)) - `opentelemetry-instrumentation-dbapi` Fix the check for the connection already being instrumented in instrument_connection(). diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py b/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py index 6323ad9bbe..a134f090fd 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py @@ -232,12 +232,13 @@ async def on_request_exception( if trace_config_ctx.span is None: return - if callable(response_hook): - response_hook(trace_config_ctx.span, params) - if trace_config_ctx.span.is_recording() and params.exception: trace_config_ctx.span.set_status(Status(StatusCode.ERROR)) trace_config_ctx.span.record_exception(params.exception) + + if callable(response_hook): + response_hook(trace_config_ctx.span, params) + _end_trace(trace_config_ctx) def _trace_config_ctx_factory(**kwargs):