Comments (2)
Thank you for the bug report!
Looking at this test, I believe what's happening is that we use https://pkg.go.dev/time#Time.Truncate to split time into intervals. If some of the test data is added before the interval boundary, and some of it is added after the boundary, we'll end up with two intervals for this test, and the test expects only one.
One way to fix this might be to increase the interval in that test slightly from 10ms to 20ms (to give us more buffer). Then when we get the first interval, wait for it to finish (the done
chan was added recently in #125), and add all the metrics immediately after it finishes:
interval := 20 * time.Millisecond
inm := NewInmemSink(interval, 50*time.Millisecond)
<- inm.getInterval().done
// add all the sample metrics
data := inm.Data()
// now we expect 2 intervals in data instead of one.
...
As long as all the metrics can be added in 20ms and we call DisplayMetrics
before the next interval, the test should not longer flake.
Edit: Ah but done
is only closed when something calls getInterval
, so we'll also need a goroutine to call that constantly to get the signal. Maybe using a time.After
to wait on the interval boundary would be easier than using the done
channel.
There are probably other options for fixing it as well.
from go-metrics.
Edit: Ah but done is only closed when something calls getInterval, so we'll also need a goroutine to call that constantly to get the signal. Maybe using a time.After to wait on the interval boundary would be easier than using the done channel.
I can confirm that. I tried the change you suggested above, and the test gets stuck, and finally times out after 10 minutes.
Logs for reference:
=== RUN TestDisplayMetrics
panic: test timed out after 10m0s
goroutine 7 [running]:
testing.(*M).startAlarm.func1()
/usr/lib/go-1.16/src/testing/testing.go:1700 +0xe5
created by time.goFunc
/usr/lib/go-1.16/src/time/sleep.go:180 +0x45
goroutine 1 [chan receive]:
testing.(*T).Run(0xc000001b00, 0x66fce6, 0x12, 0x6809f8, 0x48f0a6)
/usr/lib/go-1.16/src/testing/testing.go:1239 +0x2da
testing.runTests.func1(0xc000001980)
/usr/lib/go-1.16/src/testing/testing.go:1511 +0x78
testing.tRunner(0xc000001980, 0xc00010dde0)
/usr/lib/go-1.16/src/testing/testing.go:1193 +0xef
testing.runTests(0xc00000e0d8, 0x7f0040, 0x2a, 0x2a, 0xc047e14ce3db0d3d, 0x8bb2e16fb0, 0x7f54c0, 0x66e426)
/usr/lib/go-1.16/src/testing/testing.go:1509 +0x2fe
testing.(*M).Run(0xc000154000, 0x0)
/usr/lib/go-1.16/src/testing/testing.go:1417 +0x1eb
main.main()
_testmain.go:127 +0x138
goroutine 6 [chan receive]:
github.com/armon/go-metrics.TestDisplayMetrics(0xc000001b00)
/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/src/github.com/armon/go-metrics/inmem_endpoint_test.go:18 +0xe5
testing.tRunner(0xc000001b00, 0x6809f8)
/usr/lib/go-1.16/src/testing/testing.go:1193 +0xef
created by testing.(*T).Run
/usr/lib/go-1.16/src/testing/testing.go:1238 +0x2b3
from go-metrics.
Related Issues (20)
- Metric emission methods in metrics.go modify input key slice HOT 3
- in-mem flattenkey is non-performant HOT 1
- TestMetrics_MeasureSince is faling on arm64 HOT 1
- Deprecate Hostname usage in DogStatsdSink
- collector collisions HOT 1
- Please update prometheus lib to 1.11.1 due to CVE-2022-21698 HOT 1
- feat: support value based label filtering
- Prometheus sink handling of metric help is incorrect
- Multiple reports produced on SIGUSR1 HOT 1
- feat: add Inc & Dec method for Gauge
- feat: Support float64 gauges
- FanoutSink key modified across sinks when DogStatsdSink is enabled
- tests are broken: statsd_test.go:78: bad line gauge.val:1.000000|g
- Provide more stats for aggregated samples
- Timestamp shoud be .... a (float) timestamp
- Why not use float64?
- README.md Examples do not work HOT 1
- Support labels with the same key in the inmem_endpoint.go implementation HOT 1
- Race condition in in `DisplayMetrics`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-metrics.