Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 5c476f6

Browse files
committed
disable tracing for healthchecks
1 parent 4b0b8c1 commit 5c476f6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

api/middleware/tracer.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ func (rw *TracingResponseWriter) Write(b []byte) (int, error) {
2424
return rw.ResponseWriter.Write(b)
2525
}
2626

27+
func DisableTracing(c *Context) {
28+
c.Data["noTrace"] = true
29+
}
30+
2731
// Tracer returns a middleware that traces requests
2832
func Tracer(tracer opentracing.Tracer) macaron.Handler {
2933
return func(macCtx *macaron.Context) {
30-
3134
path := pathSlug(macCtx.Req.URL.Path)
3235
// graphite cluster requests use local=1
3336
// 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 {
6265
// call next handler. This will return after all handlers
6366
// have completed and the request has been sent.
6467
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+
6575
status := rw.Status()
6676
ext.HTTPStatusCode.Set(span, uint16(status))
6777
if status >= 200 && status < 300 {

api/routes.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ func (s *Server) RegisterRoutes() {
2424
withOrg := middleware.RequireOrg()
2525
cBody := middleware.CaptureBody
2626
ready := middleware.NodeReady()
27+
noTrace := middleware.DisableTracing
2728

28-
r.Get("/", s.appStatus)
29-
r.Get("/node", s.getNodeStatus)
29+
r.Get("/", noTrace, s.appStatus)
30+
r.Get("/node", noTrace, s.getNodeStatus)
3031
r.Post("/node", bind(models.NodeStatus{}), s.setNodeStatus)
3132
r.Get("/priority", s.explainPriority)
3233
r.Get("/debug/pprof/block", blockHandler)

0 commit comments

Comments
 (0)