cli: Add metric for number of hook invocations
This commit is contained in:
parent
8fd18364e7
commit
578731ab0b
|
@ -50,6 +50,12 @@ func SetupHookMetrics() {
|
||||||
MetricsHookErrorsTotal.WithLabelValues(string(hooks.HookPostCreate)).Add(0)
|
MetricsHookErrorsTotal.WithLabelValues(string(hooks.HookPostCreate)).Add(0)
|
||||||
MetricsHookErrorsTotal.WithLabelValues(string(hooks.HookPreCreate)).Add(0)
|
MetricsHookErrorsTotal.WithLabelValues(string(hooks.HookPreCreate)).Add(0)
|
||||||
MetricsHookErrorsTotal.WithLabelValues(string(hooks.HookPreFinish)).Add(0)
|
MetricsHookErrorsTotal.WithLabelValues(string(hooks.HookPreFinish)).Add(0)
|
||||||
|
MetricsHookInvocationsTotal.WithLabelValues(string(hooks.HookPostFinish)).Add(0)
|
||||||
|
MetricsHookInvocationsTotal.WithLabelValues(string(hooks.HookPostTerminate)).Add(0)
|
||||||
|
MetricsHookInvocationsTotal.WithLabelValues(string(hooks.HookPostReceive)).Add(0)
|
||||||
|
MetricsHookInvocationsTotal.WithLabelValues(string(hooks.HookPostCreate)).Add(0)
|
||||||
|
MetricsHookInvocationsTotal.WithLabelValues(string(hooks.HookPreCreate)).Add(0)
|
||||||
|
MetricsHookInvocationsTotal.WithLabelValues(string(hooks.HookPreFinish)).Add(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetupPreHooks(config *handler.Config) error {
|
func SetupPreHooks(config *handler.Config) error {
|
||||||
|
@ -132,6 +138,8 @@ func invokeHookSync(typ hooks.HookType, info handler.HookEvent, captureOutput bo
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetricsHookInvocationsTotal.WithLabelValues(string(typ)).Add(1)
|
||||||
|
|
||||||
id := info.Upload.ID
|
id := info.Upload.ID
|
||||||
size := info.Upload.Size
|
size := info.Upload.Size
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,18 @@ var MetricsHookErrorsTotal = prometheus.NewCounterVec(
|
||||||
[]string{"hooktype"},
|
[]string{"hooktype"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var MetricsHookInvocationsTotal = prometheus.NewCounterVec(
|
||||||
|
prometheus.CounterOpts{
|
||||||
|
Name: "tusd_hook_invocations_total",
|
||||||
|
Help: "Total number of invocations per hook type.",
|
||||||
|
},
|
||||||
|
[]string{"hooktype"},
|
||||||
|
)
|
||||||
|
|
||||||
func SetupMetrics(handler *handler.Handler) {
|
func SetupMetrics(handler *handler.Handler) {
|
||||||
prometheus.MustRegister(MetricsOpenConnections)
|
prometheus.MustRegister(MetricsOpenConnections)
|
||||||
prometheus.MustRegister(MetricsHookErrorsTotal)
|
prometheus.MustRegister(MetricsHookErrorsTotal)
|
||||||
|
prometheus.MustRegister(MetricsHookInvocationsTotal)
|
||||||
prometheus.MustRegister(prometheuscollector.New(handler.Metrics))
|
prometheus.MustRegister(prometheuscollector.New(handler.Metrics))
|
||||||
|
|
||||||
stdout.Printf("Using %s as the metrics path.\n", Flags.MetricsPath)
|
stdout.Printf("Using %s as the metrics path.\n", Flags.MetricsPath)
|
||||||
|
|
Loading…
Reference in New Issue