File tree 1 file changed +11
-9
lines changed
1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -77,19 +77,21 @@ type traceLogHandler struct {
77
77
// Trace the service function handler execution
78
78
func (h * traceLogHandler ) ServeHTTP (w http.ResponseWriter , r * http.Request ) {
79
79
span := sentry .TransactionFromContext (r .Context ())
80
- defer span .Finish ()
81
-
82
- ctx := span .Context ()
83
80
84
- span .SetData ("req_id" , log .RequestIDFromContext (ctx ))
85
- span .SetData ("path" , r .URL .Path )
86
- span .SetData ("method" , r .Method )
81
+ if span != nil {
82
+ span .SetData ("req_id" , log .RequestIDFromContext (r .Context ()))
83
+ span .SetData ("path" , r .URL .Path )
84
+ span .SetData ("method" , r .Method )
85
+ }
87
86
88
87
ww := mutil .WrapWriter (w )
89
88
90
- h .next .ServeHTTP (ww , r .WithContext (ctx ))
91
- span .SetData ("bytes" , ww .BytesWritten ())
92
- span .SetData ("status_code" , ww .Status ())
89
+ h .next .ServeHTTP (ww , r )
90
+
91
+ if span != nil {
92
+ span .SetData ("bytes" , ww .BytesWritten ())
93
+ span .SetData ("status_code" , ww .Status ())
94
+ }
93
95
}
94
96
95
97
// TraceLogHandler generates a tracing handler that adds logging data to existing handler.
You can’t perform that action at this time.
0 commit comments