-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
913fb78
commit 911d3c5
Showing
5 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
empty_flush | ||
*.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |