From c2d3043202c4847ebe1b9292db239686eb8bcc23 Mon Sep 17 00:00:00 2001 From: Nils Borrmann <98901461+nils-borrmann-y42@users.noreply.github.com> Date: Thu, 20 Oct 2022 23:29:05 +0200 Subject: [PATCH 1/2] aiohttp-client: Allow overriding of span status --- .../instrumentation/aiohttp_client/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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): From ba6788b855c1bcc211c6093f4e525f54a29df624 Mon Sep 17 00:00:00 2001 From: Nils Borrmann Date: Thu, 20 Oct 2022 23:35:50 +0200 Subject: [PATCH 2/2] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e26036875..a80ed1beb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1369](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1369)) - `opentelemetry-instrumentation-system-metrics` add supports to collect system thread count. ([#1339](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1339)) - `opentelemetry-exporter-richconsole` Fixing RichConsoleExpoter to allow multiple traces, fixing duplicate spans and include resources ([#1336](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1336)) +- `opentelemetry-instrumentation-aiohttp-client` Allow overriding of status in response hook. ([#1394](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1394)) ## [1.13.0-0.34b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.13.0-0.34b0) - 2022-09-26