Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2019-10-02 17:18:43 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2019-10-03 16:18:48 +0300
commitb1b21719d9a83f67df173033d1ea19f649e83111 (patch)
tree9b0cbac7279471bf6bc2f5c70806207931669694
parent573289b79a0c2e961cf123960f48606316c57207 (diff)
Add a gauge to track in flight commands
Running commands is not something that's currently tracked. Adding a Gauge in prometheus to track it and allow this to be trackend and potentially alerted on. Closes https://gitlab.com/gitlab-org/gitaly/issues/1844
-rw-r--r--internal/command/command.go2
-rw-r--r--internal/command/metrics.go14
2 files changed, 16 insertions, 0 deletions
diff --git a/internal/command/command.go b/internal/command/command.go
index a89be98cf..ae374f3a8 100644
--- a/internal/command/command.go
+++ b/internal/command/command.go
@@ -243,6 +243,7 @@ func New(ctx context.Context, cmd *exec.Cmd, stdin io.Reader, stdout, stderr io.
if err := cmd.Start(); err != nil {
return nil, fmt.Errorf("GitCommand: start %v: %v", cmd.Args, err)
}
+ inFlightCommandGauge.Inc()
// The goroutine below is responsible for terminating and reaping the
// process when ctx is canceled.
@@ -359,6 +360,7 @@ func (c *Command) wait() {
}
}
+ inFlightCommandGauge.Dec()
c.logProcessComplete(c.context, exitCode)
if w := c.stderrCloser; w != nil {
diff --git a/internal/command/metrics.go b/internal/command/metrics.go
new file mode 100644
index 000000000..a089b8cd8
--- /dev/null
+++ b/internal/command/metrics.go
@@ -0,0 +1,14 @@
+package command
+
+import "github.com/prometheus/client_golang/prometheus"
+
+var inFlightCommandGauge = prometheus.NewGauge(
+ prometheus.GaugeOpts{
+ Name: "gitaly_commands_running",
+ Help: "Total number of processes currently being executed",
+ },
+)
+
+func init() {
+ prometheus.MustRegister(inFlightCommandGauge)
+}