Skip to content

Commit 5632d1b

Browse files
committed
properly deal with hooks not being set
1 parent a7a4949 commit 5632d1b

File tree

1 file changed

+5
-4
lines changed
  • instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi

1 file changed

+5
-4
lines changed

instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,11 @@ def build_middleware_stack(self: Starlette) -> ASGIApp:
297297
def failsafe(func):
298298
@functools.wraps(func)
299299
def wrapper(span: Span, *args, **kwargs):
300-
try:
301-
func(span, *args, **kwargs)
302-
except Exception as exc: # pylint: disable=W0718
303-
span.record_exception(exc)
300+
if func is not None:
301+
try:
302+
func(span, *args, **kwargs)
303+
except Exception as exc: # pylint: disable=W0718
304+
span.record_exception(exc)
304305

305306
return wrapper
306307

0 commit comments

Comments
 (0)