From faa7069295997c4c508310fccaa8d5d3663cddd8 Mon Sep 17 00:00:00 2001 From: Dylan Ratcliffe Date: Thu, 18 Jul 2024 14:11:28 +0000 Subject: [PATCH] Captures interrupts as an error in the span Fixes #471 --- cmd/root.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index 67aa9a9b..7118c876 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -28,6 +28,7 @@ import ( "github.com/uptrace/opentelemetry-go-extra/otellogrus" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/trace" "golang.org/x/oauth2" ) @@ -196,10 +197,14 @@ func Execute() { // regular signals. go func() { select { - case <-sigs: + case signal := <-sigs: log.Info("Received signal, shutting down") if cmdSpan != nil { cmdSpan.SetAttributes(attribute.Bool("ovm.cli.aborted", true)) + cmdSpan.AddEvent("CLI Aborted", trace.WithAttributes( + attribute.String("ovm.cli.signal", signal.String()), + )) + cmdSpan.SetStatus(codes.Error, "CLI aborted by user") } cancel() case <-ctx.Done():