overflow metrics

This commit is contained in:
Jakob Ketterl 2019-09-15 12:23:35 +02:00
parent 7689d1a2e2
commit 392c226cbe

View File

@ -53,11 +53,17 @@ class WsjtQueue(Queue):
metrics.addMetric("wsjt.queue.in", self.inCounter) metrics.addMetric("wsjt.queue.in", self.inCounter)
self.outCounter = CounterMetric() self.outCounter = CounterMetric()
metrics.addMetric("wsjt.queue.out", self.outCounter) metrics.addMetric("wsjt.queue.out", self.outCounter)
self.overflowCounter = CounterMetric()
metrics.addMetric("wsjt.queue.overflow", self.overflowCounter)
self.workers = [self.newWorker() for _ in range(0, workers)] self.workers = [self.newWorker() for _ in range(0, workers)]
def put(self, item): def put(self, item):
self.inCounter.inc() self.inCounter.inc()
try:
super(WsjtQueue, self).put(item, block=False) super(WsjtQueue, self).put(item, block=False)
except Full:
self.overflowCounter.inc()
raise
def get(self, **kwargs): def get(self, **kwargs):
# super.get() is blocking, so it would mess up the stats to inc() first # super.get() is blocking, so it would mess up the stats to inc() first