diff --git a/modules/git/command.go b/modules/git/command.go index f800e5f3d5..f9bd1551c1 100644 --- a/modules/git/command.go +++ b/modules/git/command.go @@ -41,20 +41,20 @@ var ( // defaultCommandExecutionTimeout default command execution timeout duration defaultCommandExecutionTimeout = 360 * time.Second - reqInflightGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{ + reqInflightGauge = promauto.NewGauge(prometheus.GaugeOpts{ Namespace: "gitea", Subsystem: "git", Name: "active_commands", Help: "Number of active git subprocesses.", - }, []string{gitOperation}) - // reqDurationHistogram tracks the time taken by http request - reqDurationHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{ + }) + // reqDurationHistogram tracks the time taken by git call + reqDurationHistogram = promauto.NewHistogram(prometheus.HistogramOpts{ Namespace: "gitea", Subsystem: "git", Name: "command_duration_seconds", // diverge from spec to store the unit in metric. Help: "Measures the time taken by git subprocesses", Buckets: []float64{0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 30, 60, 120, 300}, // based on dotnet buckets https://github.com/open-telemetry/semantic-conventions/issues/336 - }, []string{gitOperation}) + }) ) // DefaultLocale is the default LC_ALL to run git commands in. @@ -335,7 +335,7 @@ func (c *Command) run(ctx context.Context, skip int, opts *RunOpts) error { desc := fmt.Sprintf("git.Run(by:%s, repo:%s): %s", callerInfo, logArgSanitize(opts.Dir), cmdLogString) log.Debug("git.Command: %s", desc) - inflight := reqInflightGauge.WithLabelValues(c.args[0]) // add command type + inflight := reqInflightGauge // add command type inflight.Inc() defer inflight.Dec() @@ -388,7 +388,7 @@ func (c *Command) run(ctx context.Context, skip int, opts *RunOpts) error { if elapsed > time.Second { log.Debug("slow git.Command.Run: %s (%s)", c, elapsed) } - reqDurationHistogram.WithLabelValues(c.args[0]).Observe(elapsed.Seconds()) + reqDurationHistogram.Observe(elapsed.Seconds()) // We need to check if the context is canceled by the program on Windows. // This is because Windows does not have signal checking when terminating the process.