0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-15 21:53:07 +02:00

drop label

to be reintroduced later, for now it would require figuring out which
arg is the actual command
This commit is contained in:
TheFox0x7 2025-07-07 15:38:40 +02:00
parent 6e64232f42
commit d310cd08f8
No known key found for this signature in database
GPG Key ID: 6CA33903484AF7C2

View File

@ -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.