-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch from counter to a gauge for partitions held #1485
Conversation
Counters cannot be decremented in Prometheus: ``` panic: counter cannot decrease in value goroutine 895 [running]: github.com/jaegertracing/jaeger/vendor/github.com/prometheus/client_golang/prometheus.(*counter).Add(0xc000790600, 0xbff0000000000000) /home/travis/gopath/src/github.com/jaegertracing/jaeger/vendor/github.com/prometheus/client_golang/prometheus/counter.go:71 +0xa3 github.com/jaegertracing/jaeger/vendor/github.com/uber/jaeger-lib/metrics/prometheus.(*counter).Inc(0xc0006b42a0, 0xffffffffffffffff) /home/travis/gopath/src/github.com/jaegertracing/jaeger/vendor/github.com/uber/jaeger-lib/metrics/prometheus/factory.go:183 +0x46 github.com/jaegertracing/jaeger/cmd/ingester/app/consumer.(*Consumer).handleMessages(0xc0004c4300, 0xf08c60, 0xc00054e630) /home/travis/gopath/src/github.com/jaegertracing/jaeger/cmd/ingester/app/consumer/consumer.go:124 +0x893 created by github.com/jaegertracing/jaeger/cmd/ingester/app/consumer.(*Consumer).Start.func1 /home/travis/gopath/src/github.com/jaegertracing/jaeger/cmd/ingester/app/consumer/consumer.go:87 +0xbd ``` Gauges can, even though we have to keep an extra variable around to keep count. In Prometheus Go library itself that is not necessary as Gauge type provides `Inc` and `Dec`, but Jaeger's wrapper does not have those exposed. Fixes jaegertracing#1200. Signed-off-by: Ivan Babrou <[email protected]>
5e32ed2
to
fa84803
Compare
Codecov Report
@@ Coverage Diff @@
## master #1485 +/- ##
==========================================
+ Coverage 99.81% 99.81% +<.01%
==========================================
Files 180 180
Lines 8631 8637 +6
==========================================
+ Hits 8615 8621 +6
Misses 8 8
Partials 8 8
Continue to review full report at Codecov.
|
@@ -109,8 +110,12 @@ func (c *Consumer) Close() error { | |||
|
|||
func (c *Consumer) handleMessages(pc sc.PartitionConsumer) { | |||
c.logger.Info("Starting message handler", zap.Int32("partition", pc.Partition())) | |||
c.partitionsHeld.Inc(1) | |||
defer c.partitionsHeld.Inc(-1) | |||
c.partitionsHeld++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this require some sort of synchronization? L92 starts handleMessages
as a goroutine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're probably right, so I moved partitionMapLock.Lock()
around to encompass this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like c.partitionMapLock.Lock()
should be enough
similar PR #1254 |
3cd65d2
to
d3c9ccd
Compare
c.partitionsHeld-- | ||
c.partitionsHeldGauge.Update(c.partitionsHeld) | ||
c.partitionMapLock.Unlock() | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend moving this after L123 (after unlock) and combining L124-125 into the same defer func()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, amended.
Signed-off-by: Ivan Babrou <[email protected]>
d3c9ccd
to
2582040
Compare
CI is happy ✅ |
Thanks for the PR! |
Counters cannot be decremented in Prometheus:
Gauges can, even though we have to keep an extra variable around to keep count. In Prometheus Go library itself that is not necessary as Gauge type provides
Inc
andDec
, but Jaeger's wrapper does not have those exposed.Fixes #1200.
Signed-off-by: Ivan Babrou [email protected]