From 732baad7c542b6afa16c38eca52c34172a619b5e Mon Sep 17 00:00:00 2001 From: Will Gorman Date: Mon, 11 Oct 2021 22:39:37 -0500 Subject: [PATCH] Skip pass actions if no test name is present (#8) Go test json may produce output like: {"Time":"2021-10-07T15:05:01.541387-05:00","Action":"pass","Package":"github.com/example/package","Elapsed":0.023} Instead of returning from the goroutine and hanging go-test-trace, just skip it. --- README.md | 4 ++-- main.go | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bd3f4e8..c4e941b 100644 --- a/README.md +++ b/README.md @@ -62,14 +62,14 @@ $ go test -v ./example | go-test-trace -stdin You can export to any collector by using the endpoint flag: ``` -$ go-test-trace ./example -endpoint=my-otel-collector.io:9090 +$ go-test-trace -endpoint=my-otel-collector.io:9090 ./example ``` You can make the go-test-trace to participate into an existing trace with the traceparent flag. ``` -$ go-test-trace ./example -traceparent=00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01 +$ go-test-trace -traceparent=00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01 ./example ``` ## Running the collector diff --git a/main.go b/main.go index ee78f0a..485cacf 100644 --- a/main.go +++ b/main.go @@ -139,6 +139,9 @@ func trace(args []string) error { startTime: data.Time, } case "pass", "fail", "skip": + if data.Test == "" { + continue + } spanData, ok := collectedSpans[data.Test] if !ok { return // should never happen