add wsprnet metrics

This commit is contained in:
Jakob Ketterl 2021-01-15 00:11:20 +01:00
parent 1b36baad88
commit a65f15869b

View File

@ -2,6 +2,7 @@ from owrx.reporting import Reporter
from owrx.version import openwebrx_version from owrx.version import openwebrx_version
from owrx.config import Config from owrx.config import Config
from owrx.locator import Locator from owrx.locator import Locator
from owrx.metrics import Metrics, CounterMetric
from queue import Queue, Full from queue import Queue, Full
from urllib import request, parse from urllib import request, parse
import threading import threading
@ -10,6 +11,7 @@ from datetime import datetime, timezone
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class Worker(threading.Thread): class Worker(threading.Thread):
def __init__(self, queue: Queue): def __init__(self, queue: Queue):
self.queue = queue self.queue = queue
@ -62,12 +64,18 @@ class WsprnetReporter(Reporter):
# single worker # single worker
Worker(self.queue).start() Worker(self.queue).start()
# metrics
metrics = Metrics.getSharedInstance()
self.spotCounter = CounterMetric()
metrics.addMetric("wsprnet.spots", self.spotCounter)
def stop(self): def stop(self):
pass pass
def spot(self, spot): def spot(self, spot):
try: try:
self.queue.put(spot, block=False) self.queue.put(spot, block=False)
self.spotCounter.inc()
except Full: except Full:
logger.warning("WSPRNet Queue overflow, one spot lost") logger.warning("WSPRNet Queue overflow, one spot lost")