Skip to content

Commit

Permalink
HTTP raw route should be traceable (fixes #245)
Browse files Browse the repository at this point in the history
Signed-off-by: Sotirios Mantziaris <s.mantziaris@thebeat.co>
  • Loading branch information
mantzas authored Dec 11, 2018
1 parent 6d532c9 commit 803b83a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion sync/http/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ func healthCheckRoute(hcf HealthCheckFunc) Route {
w.WriteHeader(http.StatusOK)
}
}
return NewRouteRaw("/health", http.MethodGet, f)
return NewRouteRaw("/health", http.MethodGet, f, false)
}
2 changes: 1 addition & 1 deletion sync/http/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ func infoHandler(w http.ResponseWriter, r *http.Request) {
}

func infoRoute() Route {
return NewRouteRaw("/info", http.MethodGet, infoHandler)
return NewRouteRaw("/info", http.MethodGet, infoHandler, false)
}
2 changes: 1 addition & 1 deletion sync/http/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import (
)

func metricRoute() Route {
return NewRouteRaw("/metrics", http.MethodGet, promhttp.Handler().ServeHTTP)
return NewRouteRaw("/metrics", http.MethodGet, promhttp.Handler().ServeHTTP, false)
}
22 changes: 11 additions & 11 deletions sync/http/profiling.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import (

func profilingRoutes() []Route {
return []Route{
NewRouteRaw("/debug/pprof/", http.MethodGet, profIndex),
NewRouteRaw("/debug/pprof/allocs/", http.MethodGet, pprofAllocsIndex),
NewRouteRaw("/debug/pprof/cmdline/", http.MethodGet, profCmdline),
NewRouteRaw("/debug/pprof/profile/", http.MethodGet, profProfile),
NewRouteRaw("/debug/pprof/symbol/", http.MethodGet, profSymbol),
NewRouteRaw("/debug/pprof/trace/", http.MethodGet, profTrace),
NewRouteRaw("/debug/pprof/heap/", http.MethodGet, profHeap),
NewRouteRaw("/debug/pprof/goroutine/", http.MethodGet, profGoroutine),
NewRouteRaw("/debug/pprof/block/", http.MethodGet, profBlock),
NewRouteRaw("/debug/pprof/threadcreate/", http.MethodGet, profThreadcreate),
NewRouteRaw("/debug/pprof/mutex/", http.MethodGet, profMutex),
NewRouteRaw("/debug/pprof/", http.MethodGet, profIndex, false),
NewRouteRaw("/debug/pprof/allocs/", http.MethodGet, pprofAllocsIndex, false),
NewRouteRaw("/debug/pprof/cmdline/", http.MethodGet, profCmdline, false),
NewRouteRaw("/debug/pprof/profile/", http.MethodGet, profProfile, false),
NewRouteRaw("/debug/pprof/symbol/", http.MethodGet, profSymbol, false),
NewRouteRaw("/debug/pprof/trace/", http.MethodGet, profTrace, false),
NewRouteRaw("/debug/pprof/heap/", http.MethodGet, profHeap, false),
NewRouteRaw("/debug/pprof/goroutine/", http.MethodGet, profGoroutine, false),
NewRouteRaw("/debug/pprof/block/", http.MethodGet, profBlock, false),
NewRouteRaw("/debug/pprof/threadcreate/", http.MethodGet, profThreadcreate, false),
NewRouteRaw("/debug/pprof/mutex/", http.MethodGet, profMutex, false),
}
}

Expand Down
4 changes: 2 additions & 2 deletions sync/http/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ func NewRoute(p string, m string, pr sync.ProcessorFunc, trace bool) Route {
}

// NewRouteRaw creates a new route from a HTTP handler.
func NewRouteRaw(p string, m string, h http.HandlerFunc) Route {
return Route{Pattern: p, Method: m, Handler: h, Trace: false}
func NewRouteRaw(p string, m string, h http.HandlerFunc, trace bool) Route {
return Route{Pattern: p, Method: m, Handler: h, Trace: trace}
}
2 changes: 1 addition & 1 deletion sync/http/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestNewDeleteRoute(t *testing.T) {
assert.True(t, r.Trace)
}
func TestNewRouteRaw(t *testing.T) {
r := NewRouteRaw("/index", http.MethodGet, nil)
r := NewRouteRaw("/index", http.MethodGet, nil, false)
assert.Equal(t, "/index", r.Pattern)
assert.Equal(t, "GET", r.Method)
assert.False(t, r.Trace)
Expand Down

0 comments on commit 803b83a

Please sign in to comment.