From 274158493d087e729ae8b9c7d16ebaf8ca9dd1b2 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Tue, 26 Jul 2016 12:49:04 +0100 Subject: [PATCH] Name our routes, so /metrics gives more sensible aggregations --- app/controls.go | 9 +++++++-- app/pipes.go | 4 ++++ app/router.go | 18 ++++++++++++------ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/controls.go b/app/controls.go index 38f9a759e6..d5ef4440d9 100644 --- a/app/controls.go +++ b/app/controls.go @@ -14,9 +14,14 @@ import ( // RegisterControlRoutes registers the various control routes with a http mux. func RegisterControlRoutes(router *mux.Router, cr ControlRouter) { - router.Methods("GET").Path("/api/control/ws"). + router. + Methods("GET"). + Path("/api/control/ws"). HandlerFunc(requestContextDecorator(handleProbeWS(cr))) - router.Methods("POST").MatcherFunc(URLMatcher("/api/control/{probeID}/{nodeID}/{control}")). + router. + Methods("POST"). + Name("api_control_probeid_nodeid_control"). + MatcherFunc(URLMatcher("/api/control/{probeID}/{nodeID}/{control}")). HandlerFunc(requestContextDecorator(handleControl(cr))) } diff --git a/app/pipes.go b/app/pipes.go index f51b75e9f8..87a272a49c 100644 --- a/app/pipes.go +++ b/app/pipes.go @@ -13,18 +13,22 @@ import ( // RegisterPipeRoutes registers the pipe routes func RegisterPipeRoutes(router *mux.Router, pr PipeRouter) { router.Methods("GET"). + Name("api_pipe_pipeid_check"). Path("/api/pipe/{pipeID}/check"). HandlerFunc(requestContextDecorator(checkPipe(pr, UIEnd))) router.Methods("GET"). + Name("api_pipe_pipeid"). Path("/api/pipe/{pipeID}"). HandlerFunc(requestContextDecorator(handlePipeWs(pr, UIEnd))) router.Methods("GET"). + Name("api_pipe_pipeid_probe"). Path("/api/pipe/{pipeID}/probe"). HandlerFunc(requestContextDecorator(handlePipeWs(pr, ProbeEnd))) router.Methods("DELETE", "POST"). + Name("api_pipe_pipeid"). Path("/api/pipe/{pipeID}"). HandlerFunc(requestContextDecorator(deletePipe(pr))) } diff --git a/app/router.go b/app/router.go index 27e71ce482..1e200533c8 100644 --- a/app/router.go +++ b/app/router.go @@ -88,12 +88,18 @@ func RegisterTopologyRoutes(router *mux.Router, r Reporter) { gzipHandler(requestContextDecorator(apiHandler(r)))) get.HandleFunc("/api/topology", gzipHandler(requestContextDecorator(topologyRegistry.makeTopologyList(r)))) - get.HandleFunc("/api/topology/{topology}", - gzipHandler(requestContextDecorator(topologyRegistry.captureRenderer(r, handleTopology)))) - get.HandleFunc("/api/topology/{topology}/ws", - requestContextDecorator(captureReporter(r, handleWebsocket))) // NB not gzip! - get.MatcherFunc(URLMatcher("/api/topology/{topology}/{id}")).HandlerFunc( - gzipHandler(requestContextDecorator(topologyRegistry.captureRenderer(r, handleNode)))) + get. + HandleFunc("/api/topology/{topology}", + gzipHandler(requestContextDecorator(topologyRegistry.captureRenderer(r, handleTopology)))). + Name("api_topology_topology") + get. + HandleFunc("/api/topology/{topology}/ws", + requestContextDecorator(captureReporter(r, handleWebsocket))). // NB not gzip! + Name("api_topology_topology_ws") + get. + MatcherFunc(URLMatcher("/api/topology/{topology}/{id}")).HandlerFunc( + gzipHandler(requestContextDecorator(topologyRegistry.captureRenderer(r, handleNode)))). + Name("api_topology_topology_id") get.HandleFunc("/api/report", gzipHandler(requestContextDecorator(makeRawReportHandler(r)))) get.HandleFunc("/api/probes",