From fe4536ea9b4b8bdfeb00d0754a8e4e1c23ea925c Mon Sep 17 00:00:00 2001 From: Jim Lambert Date: Fri, 4 May 2018 10:57:29 -0400 Subject: [PATCH] allow consumers to set a router to serve metrics on --- middleware.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/middleware.go b/middleware.go index a013499..c5a1924 100644 --- a/middleware.go +++ b/middleware.go @@ -166,6 +166,15 @@ func (p *Prometheus) SetListenAddress(address string) { } } +// SetListenAddressWithRouter for using a separate router to expose metrics. (this keeps things like GET /metrics out of +// your content's access log). +func (p *Prometheus) SetListenAddressWithRouter(listenAddress string, r *gin.Engine) { + p.listenAddress = listenAddress + if len(p.listenAddress) > 0 { + p.router = r + } +} + func (p *Prometheus) setMetricsPath(e *gin.Engine) { if p.listenAddress != "" {