diff --git a/lib/ddtrace/contrib/rack/middlewares.rb b/lib/ddtrace/contrib/rack/middlewares.rb index 24a11b52c2f..5f25fa690ef 100644 --- a/lib/ddtrace/contrib/rack/middlewares.rb +++ b/lib/ddtrace/contrib/rack/middlewares.rb @@ -68,7 +68,7 @@ def call(env) # catch exceptions that may be raised in the middleware chain # Note: if a middleware catches an Exception without re raising, # the Exception cannot be recorded here. - request_span.set_error(e) + request_span.set_error(e) unless request_span.nil? raise e ensure # the source of truth in Rack is the PATH_INFO key that holds the