Skip to content

Commit

Permalink
tcp_sink: test empty flush (#93)
Browse files Browse the repository at this point in the history
* tcp_sink: test empty flush

* Run Go 1.18 in CI and update go.mod

Co-authored-by: francisco souza <[email protected]>
  • Loading branch information
charlievieth and fsouza authored Mar 28, 2022
1 parent 913fb78 commit 911d3c5
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
strategy:
matrix:
go-version:
- 1.16.x
- 1.17.x
- 1.18.x

name: run-tests
runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
module github.com/lyft/gostats

go 1.14
go 1.17

require (
github.com/kelseyhightower/envconfig v1.4.0
github.com/sirupsen/logrus v1.8.1
)

require (
github.com/stretchr/testify v1.6.1 // indirect
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 // indirect
)
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 2 additions & 0 deletions testdata/empty_flush/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
empty_flush
*.exe
43 changes: 43 additions & 0 deletions testdata/empty_flush/empty_flush.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main

import (
"errors"
"fmt"
"os"
"time"

stats "github.com/lyft/gostats"
)

const FlushTimeout = time.Second * 3

func flushStore(store stats.Store) error {
done := make(chan struct{})
go func() { store.Flush(); close(done) }()
select {
case <-done:
return nil
case <-time.After(FlushTimeout):
return errors.New("stats flush timed out")
}
}

func realMain() (err error) {
store := stats.NewDefaultStore()

scope := store.ScopeWithTags("test.service.name", map[string]string{
"wrap": "1",
})
defer func() {
err = flushStore(store)
}()
_ = scope.NewCounter("panics")
return
}

func main() {
if err := realMain(); err != nil {
fmt.Fprintln(os.Stderr, "Error:", err)
os.Exit(1)
}
}

0 comments on commit 911d3c5

Please sign in to comment.