File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -87,10 +87,6 @@ func RequestTracing(tracer tracing.Tracer) web.Middleware {
87
87
88
88
// generic span name for requests where there's no route operation name
89
89
spanName := fmt .Sprintf ("HTTP %s <unknown>" , req .Method )
90
- // TODO: do not depend on web.Context from the future
91
- if routeOperation , exists := RouteOperationName (web .FromContext (req .Context ()).Req ); exists {
92
- spanName = fmt .Sprintf ("HTTP %s %s" , req .Method , routeOperation )
93
- }
94
90
95
91
ctx , span := tracer .Start (ctx , spanName , trace .WithAttributes (
96
92
semconv .HTTPURLKey .String (req .RequestURI ),
@@ -105,6 +101,13 @@ func RequestTracing(tracer tracing.Tracer) web.Middleware {
105
101
106
102
next .ServeHTTP (rw , req )
107
103
104
+ // Reset the span name after the request has been processed, as
105
+ // the route operation may have been injected by middleware.
106
+ // TODO: do not depend on web.Context from the future
107
+ if routeOperation , exists := RouteOperationName (web .FromContext (req .Context ()).Req ); exists {
108
+ span .SetName (fmt .Sprintf ("HTTP %s %s" , req .Method , routeOperation ))
109
+ }
110
+
108
111
status := rw .Status ()
109
112
110
113
span .SetAttributes (semconv .HTTPStatusCode (status ))
You can’t perform that action at this time.
0 commit comments