This repository was archived by the owner on Aug 23, 2023. It is now read-only.
File tree 2 files changed +14
-3
lines changed
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -24,10 +24,13 @@ func (rw *TracingResponseWriter) Write(b []byte) (int, error) {
24
24
return rw .ResponseWriter .Write (b )
25
25
}
26
26
27
+ func DisableTracing (c * Context ) {
28
+ c .Data ["noTrace" ] = true
29
+ }
30
+
27
31
// Tracer returns a middleware that traces requests
28
32
func Tracer (tracer opentracing.Tracer ) macaron.Handler {
29
33
return func (macCtx * macaron.Context ) {
30
-
31
34
path := pathSlug (macCtx .Req .URL .Path )
32
35
// graphite cluster requests use local=1
33
36
// this way we can differentiate "full" render requests from client to MT (encompassing data processing, proxing to graphite, etc)
@@ -62,6 +65,13 @@ func Tracer(tracer opentracing.Tracer) macaron.Handler {
62
65
// call next handler. This will return after all handlers
63
66
// have completed and the request has been sent.
64
67
macCtx .Next ()
68
+
69
+ // if tracing has been disabled we return directly without calling
70
+ // span.Finish()
71
+ if noTrace , ok := macCtx .Data ["noTrace" ]; ok && noTrace .(bool ) {
72
+ return
73
+ }
74
+
65
75
status := rw .Status ()
66
76
ext .HTTPStatusCode .Set (span , uint16 (status ))
67
77
if status >= 200 && status < 300 {
Original file line number Diff line number Diff line change @@ -24,9 +24,10 @@ func (s *Server) RegisterRoutes() {
24
24
withOrg := middleware .RequireOrg ()
25
25
cBody := middleware .CaptureBody
26
26
ready := middleware .NodeReady ()
27
+ noTrace := middleware .DisableTracing
27
28
28
- r .Get ("/" , s .appStatus )
29
- r .Get ("/node" , s .getNodeStatus )
29
+ r .Get ("/" , noTrace , s .appStatus )
30
+ r .Get ("/node" , noTrace , s .getNodeStatus )
30
31
r .Post ("/node" , bind (models.NodeStatus {}), s .setNodeStatus )
31
32
r .Get ("/priority" , s .explainPriority )
32
33
r .Get ("/debug/pprof/block" , blockHandler )
You can’t perform that action at this time.
0 commit comments