From cefcba987170d2640118bc1b75515a2dcb09e636 Mon Sep 17 00:00:00 2001 From: Laura Brehm Date: Thu, 4 Apr 2024 19:11:56 +0100 Subject: [PATCH] otel: capture exit code as int64 Signed-off-by: Laura Brehm --- cli/command/telemetry_utils.go | 3 +-- cli/command/telemetry_utils_test.go | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cli/command/telemetry_utils.go b/cli/command/telemetry_utils.go index 7ee0bb1ff1..5749b4f18c 100644 --- a/cli/command/telemetry_utils.go +++ b/cli/command/telemetry_utils.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "strconv" "strings" "time" @@ -110,7 +109,7 @@ func attributesFromError(err error) []attribute.KeyValue { } attrs = append(attrs, attribute.String("command.error.type", otelErrorType(err))) } - attrs = append(attrs, attribute.String("command.status.code", strconv.Itoa(exitCode))) + attrs = append(attrs, attribute.Int("command.status.code", exitCode)) return attrs } diff --git a/cli/command/telemetry_utils_test.go b/cli/command/telemetry_utils_test.go index 45daaa9c70..a8520816aa 100644 --- a/cli/command/telemetry_utils_test.go +++ b/cli/command/telemetry_utils_test.go @@ -159,7 +159,7 @@ func TestAttributesFromError(t *testing.T) { testName: "no error", err: nil, expected: []attribute.KeyValue{ - attribute.String("command.status.code", "0"), + attribute.Int("command.status.code", 0), }, }, { @@ -167,7 +167,7 @@ func TestAttributesFromError(t *testing.T) { err: statusError{StatusCode: 127}, expected: []attribute.KeyValue{ attribute.String("command.error.type", "generic"), - attribute.String("command.status.code", "127"), + attribute.Int("command.status.code", 127), }, }, { @@ -175,7 +175,7 @@ func TestAttributesFromError(t *testing.T) { err: context.Canceled, expected: []attribute.KeyValue{ attribute.String("command.error.type", "canceled"), - attribute.String("command.status.code", "1"), + attribute.Int("command.status.code", 1), }, }, } {