You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py
+20-26Lines changed: 20 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -289,22 +289,33 @@ def instrument_app(
289
289
schema_url=_get_schema_url(sem_conv_opt_in_mode),
290
290
)
291
291
292
-
# Instead of using `app.add_middleware` we monkey patch `build_middleware_stack` to insert our middleware
293
-
# as the outermost middleware.
294
-
# Otherwise `OpenTelemetryMiddleware` would have unhandled exceptions tearing through it and would not be able
295
-
# to faithfully record what is returned to the client since it technically cannot know what `ServerErrorMiddleware` is going to do.
296
-
292
+
# In order to make traces available at any stage of the request
293
+
# processing - including exception handling - we wrap ourselves as
294
+
# the new, outermost middleware. However in order to prevent
295
+
# exceptions from user-provided hooks of tearing through, we wrap
0 commit comments