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:
authorSami Hiltunen <shiltunen@gitlab.com>2022-11-14 16:52:47 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2022-11-17 17:44:16 +0300
commitefe5bdd39bba37c9ecabef7f84ed46907773ac92 (patch)
tree361d396fd42bbcfa6469a29cdb7490bde785ab60
parent7767d7b2a559bbe96483823d18ebdbf24942dd58 (diff)
Simplify unit conversions when logging command completion
logProcessComplete logs some stats about a command after it has finished. It's currently doing manual conversions between from seconds to milliseconds. Change it to get the right value to begin with.
-rw-r--r--internal/command/command.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/internal/command/command.go b/internal/command/command.go
index 2881cf86f..77961eef4 100644
--- a/internal/command/command.go
+++ b/internal/command/command.go
@@ -396,10 +396,10 @@ func (c *Command) logProcessComplete() {
"path": cmd.Path,
"args": cmd.Args,
"command.exitCode": exitCode,
- "command.system_time_ms": systemTime.Seconds() * 1000,
- "command.user_time_ms": userTime.Seconds() * 1000,
- "command.cpu_time_ms": (systemTime.Seconds() + userTime.Seconds()) * 1000,
- "command.real_time_ms": realTime.Seconds() * 1000,
+ "command.system_time_ms": systemTime.Milliseconds(),
+ "command.user_time_ms": userTime.Milliseconds(),
+ "command.cpu_time_ms": systemTime.Milliseconds() + userTime.Milliseconds(),
+ "command.real_time_ms": realTime.Milliseconds(),
}
if c.cgroupPath != "" {
@@ -424,10 +424,10 @@ func (c *Command) logProcessComplete() {
if stats := StatsFromContext(ctx); stats != nil {
stats.RecordSum("command.count", 1)
- stats.RecordSum("command.system_time_ms", int(systemTime.Seconds()*1000))
- stats.RecordSum("command.user_time_ms", int(userTime.Seconds()*1000))
- stats.RecordSum("command.cpu_time_ms", int((systemTime.Seconds()+userTime.Seconds())*1000))
- stats.RecordSum("command.real_time_ms", int(realTime.Seconds()*1000))
+ stats.RecordSum("command.system_time_ms", int(systemTime.Milliseconds()))
+ stats.RecordSum("command.user_time_ms", int(userTime.Milliseconds()))
+ stats.RecordSum("command.cpu_time_ms", int(systemTime.Milliseconds()+userTime.Milliseconds()))
+ stats.RecordSum("command.real_time_ms", int(realTime.Milliseconds()))
if ok {
stats.RecordMax("command.maxrss", int(rusage.Maxrss))
@@ -457,9 +457,9 @@ func (c *Command) logProcessComplete() {
c.span.LogKV(
"pid", cmd.ProcessState.Pid(),
"exit_code", exitCode,
- "system_time_ms", int(systemTime.Seconds()*1000),
- "user_time_ms", int(userTime.Seconds()*1000),
- "real_time_ms", int(realTime.Seconds()*1000),
+ "system_time_ms", systemTime.Milliseconds(),
+ "user_time_ms", userTime.Milliseconds(),
+ "real_time_ms", realTime.Milliseconds(),
)
if ok {
c.span.LogKV(