diff --git a/cmd/tusd/cli/hooks.go b/cmd/tusd/cli/hooks.go index 1bb9210..2c7bcf3 100644 --- a/cmd/tusd/cli/hooks.go +++ b/cmd/tusd/cli/hooks.go @@ -50,6 +50,12 @@ func SetupHookMetrics() { MetricsHookErrorsTotal.WithLabelValues(string(hooks.HookPostCreate)).Add(0) MetricsHookErrorsTotal.WithLabelValues(string(hooks.HookPreCreate)).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 { @@ -132,6 +138,8 @@ func invokeHookSync(typ hooks.HookType, info handler.HookEvent, captureOutput bo return nil, nil } + MetricsHookInvocationsTotal.WithLabelValues(string(typ)).Add(1) + id := info.Upload.ID size := info.Upload.Size diff --git a/cmd/tusd/cli/metrics.go b/cmd/tusd/cli/metrics.go index 97c4ccb..5ecd8e2 100644 --- a/cmd/tusd/cli/metrics.go +++ b/cmd/tusd/cli/metrics.go @@ -23,9 +23,18 @@ var MetricsHookErrorsTotal = prometheus.NewCounterVec( []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) { prometheus.MustRegister(MetricsOpenConnections) prometheus.MustRegister(MetricsHookErrorsTotal) + prometheus.MustRegister(MetricsHookInvocationsTotal) prometheus.MustRegister(prometheuscollector.New(handler.Metrics)) stdout.Printf("Using %s as the metrics path.\n", Flags.MetricsPath)