diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2019-10-04 13:25:47 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2019-10-04 13:25:47 +0300 |
commit | e50f810ae08d2c9117db2d713fd6eab67abc890d (patch) | |
tree | b643134bd585c5fffee9275d65a0f8a270eefc2f | |
parent | 4fb437eaa72ca8ce5d305f253fbb2c62e41f6828 (diff) | |
parent | b1b21719d9a83f67df173033d1ea19f649e83111 (diff) |
Merge branch 'zj-in-flight-requests' into 'master'
Add a gauge to track in flight commands
Closes #1844
See merge request gitlab-org/gitaly!1531
-rw-r--r-- | internal/command/command.go | 2 | ||||
-rw-r--r-- | internal/command/metrics.go | 14 |
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) +} |