Skip to content

Commit

Permalink
Do not pass a nil WaitGroup to the exporter in one_shot mode.
Browse files Browse the repository at this point in the history
Fixes #783.
  • Loading branch information
jaqx0r committed Jan 14, 2024
1 parent 4ea81a1 commit 5a6a321
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/mtail/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os/signal"
"runtime"
"strings"
"sync"
"syscall"
"time"

Expand Down Expand Up @@ -248,19 +249,23 @@ func main() {
if *oneShot {
switch *oneShotFormat {
case "prometheus":
e, err := exporter.New(ctx, nil, store, eOpts...)
var wg sync.WaitGroup
e, err := exporter.New(ctx, &wg, store, eOpts...)
if err != nil {
glog.Error(err)
cancel()
wg.Wait()
os.Exit(1) //nolint:gocritic // false positive
}
err = e.Write(os.Stdout)
if err != nil {
glog.Error(err)
cancel()
wg.Wait()
os.Exit(1) //nolint:gocritic // false positive
}
cancel()
wg.Wait()
os.Exit(0) //nolint:gocritic // false positive
case "json":
err = store.WriteMetrics(os.Stdout)
Expand Down

0 comments on commit 5a6a321

Please sign in to comment.