Add -metrics-path flag for configuring the metrics endpoint
Addresses #52
This commit is contained in:
parent
930a63c058
commit
30edfb1209
|
@ -17,6 +17,7 @@ var Flags struct {
|
|||
HooksDir string
|
||||
ShowVersion bool
|
||||
ExposeMetrics bool
|
||||
MetricsPath string
|
||||
BehindProxy bool
|
||||
|
||||
HooksInstalled bool
|
||||
|
@ -34,6 +35,7 @@ func ParseFlags() {
|
|||
flag.StringVar(&Flags.HooksDir, "hooks-dir", "", "Directory to search for available hooks scripts")
|
||||
flag.BoolVar(&Flags.ShowVersion, "version", false, "Print tusd version information")
|
||||
flag.BoolVar(&Flags.ExposeMetrics, "expose-metrics", true, "Expose metrics about tusd usage")
|
||||
flag.StringVar(&Flags.MetricsPath, "metrics-path", "/metrics", "Path under which the metrics endpoint will be accessible")
|
||||
flag.BoolVar(&Flags.BehindProxy, "behind-proxy", false, "Respect X-Forwarded-* and similar headers which may be set by proxies")
|
||||
|
||||
flag.Parse()
|
||||
|
|
|
@ -18,5 +18,6 @@ func SetupMetrics(handler *tusd.Handler) {
|
|||
prometheus.MustRegister(MetricsOpenConnections)
|
||||
prometheus.MustRegister(prometheuscollector.New(handler.Metrics))
|
||||
|
||||
http.Handle("/metrics", prometheus.Handler())
|
||||
stdout.Printf("Using %s as the metrics path.\n", Flags.MetricsPath)
|
||||
http.Handle(Flags.MetricsPath, prometheus.Handler())
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ func Serve() {
|
|||
|
||||
stdout.Printf("Using %s as address to listen.\n", address)
|
||||
stdout.Printf("Using %s as the base path.\n", basepath)
|
||||
stdout.Printf(Composer.Capabilities())
|
||||
|
||||
SetupPostHooks(handler)
|
||||
|
||||
|
@ -35,6 +34,8 @@ func Serve() {
|
|||
SetupMetrics(handler)
|
||||
}
|
||||
|
||||
stdout.Printf(Composer.Capabilities())
|
||||
|
||||
// Do not display the greeting if the tusd handler will be mounted at the root
|
||||
// path. Else this would cause a "multiple registrations for /" panic.
|
||||
if basepath != "/" {
|
||||
|
|
Loading…
Reference in New Issue