Skip to content

Commit 59b087e

Browse files
nils-borrmann-y42CircleCI
authored and
CircleCI
committed
aiohttp-client: Allow overriding of span status (open-telemetry#1394)
1 parent 393e686 commit 59b087e

File tree

2 files changed

+6
-3
lines changed
  • instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client

2 files changed

+6
-3
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

1919
- Fix bug in Urllib instrumentation - add status code to span attributes only if the status code is not None.
2020
([#1430](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1430))
21+
- `opentelemetry-instrumentation-aiohttp-client` Allow overriding of status in response hook.
22+
([#1394](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1394))
2123
- `opentelemetry-instrumentation-pymysql` Fix dbapi connection instrument wrapper has no _sock member.
2224
([#1424](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1424))
2325
- `opentelemetry-instrumentation-dbapi` Fix the check for the connection already being instrumented in instrument_connection().

instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,13 @@ async def on_request_exception(
232232
if trace_config_ctx.span is None:
233233
return
234234

235-
if callable(response_hook):
236-
response_hook(trace_config_ctx.span, params)
237-
238235
if trace_config_ctx.span.is_recording() and params.exception:
239236
trace_config_ctx.span.set_status(Status(StatusCode.ERROR))
240237
trace_config_ctx.span.record_exception(params.exception)
238+
239+
if callable(response_hook):
240+
response_hook(trace_config_ctx.span, params)
241+
241242
_end_trace(trace_config_ctx)
242243

243244
def _trace_config_ctx_factory(**kwargs):

0 commit comments

Comments
 (0)