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:
authorIgor Wiedler <iwiedler@gitlab.com>2022-04-08 12:04:31 +0300
committerIgor Wiedler <iwiedler@gitlab.com>2022-04-08 12:04:31 +0300
commit549282123914565b8cb2532b028fc195a3e8fef8 (patch)
treee3242a410ed65667e0a7e98299db30ab36779674
parenta088c9b3e51e22df4e5274e2ae26b112552c01e1 (diff)
Override for command stats metrics cmd label
For linguist, we prepend `env` as well as `bundle exec` to the exec invocation. For better accounting, we can override this, so that it shows `git-linguist` instead of `env` as the cmd".
-rw-r--r--internal/command/command.go15
-rw-r--r--internal/gitaly/linguist/linguist.go1
2 files changed, 13 insertions, 3 deletions
diff --git a/internal/command/command.go b/internal/command/command.go
index 45167aab4..85178d995 100644
--- a/internal/command/command.go
+++ b/internal/command/command.go
@@ -150,10 +150,11 @@ type Command struct {
waitError error
waitOnce sync.Once
- metricsSubCmd string
- span opentracing.Span
+ span opentracing.Span
- cgroupPath string
+ metricsCmd string
+ metricsSubCmd string
+ cgroupPath string
}
type stdinSentinel struct{}
@@ -202,6 +203,11 @@ func (c *Command) SetCgroupPath(path string) {
c.cgroupPath = path
}
+// SetMetricsCmd overrides the "cmd" label used in metrics
+func (c *Command) SetMetricsCmd(metricsCmd string) {
+ c.metricsCmd = metricsCmd
+}
+
// SetMetricsSubCmd sets the "subcmd" label used in metrics
func (c *Command) SetMetricsSubCmd(metricsSubCmd string) {
c.metricsSubCmd = metricsSubCmd
@@ -451,6 +457,9 @@ func (c *Command) logProcessComplete() {
if featureflag.CommandStatsMetrics.IsEnabled(ctx) {
service, method := methodFromContext(ctx)
cmdName := path.Base(c.cmd.Path)
+ if c.metricsCmd != "" {
+ cmdName = c.metricsCmd
+ }
cpuSecondsTotal.WithLabelValues(service, method, cmdName, c.metricsSubCmd, "system").Add(systemTime.Seconds())
cpuSecondsTotal.WithLabelValues(service, method, cmdName, c.metricsSubCmd, "user").Add(userTime.Seconds())
realSecondsTotal.WithLabelValues(service, method, cmdName, c.metricsSubCmd).Add(realTime.Seconds())
diff --git a/internal/gitaly/linguist/linguist.go b/internal/gitaly/linguist/linguist.go
index 9c498e0cf..9786e6547 100644
--- a/internal/gitaly/linguist/linguist.go
+++ b/internal/gitaly/linguist/linguist.go
@@ -128,6 +128,7 @@ func (inst *Instance) startGitLinguist(ctx context.Context, repoPath string, com
return nil, fmt.Errorf("creating command: %w", err)
}
+ internalCmd.SetMetricsCmd("git-linguist")
internalCmd.SetMetricsSubCmd(linguistCommand)
return internalCmd, nil