Пример #1
0
    def __init__(self):
        # max 100 entries
        self.queue = Queue(100)
        # single worker
        Worker(self.queue).start()

        # metrics
        metrics = Metrics.getSharedInstance()
        self.spotCounter = CounterMetric()
        metrics.addMetric("wsprnet.spots", self.spotCounter)
Пример #2
0
 def __init__(self):
     self.spots = []
     self.spotLock = threading.Lock()
     self.uploader = Uploader()
     self.timer = None
     metrics = Metrics.getSharedInstance()
     self.dupeCounter = CounterMetric()
     metrics.addMetric("pskreporter.duplicates", self.dupeCounter)
     self.spotCounter = CounterMetric()
     metrics.addMetric("pskreporter.spots", self.spotCounter)
Пример #3
0
 def pushDecode(self):
     band = "unknown"
     if self.band is not None:
         band = self.band.getName()
     name = "digiham.decodes.{band}.pocsag".format(band=band)
     metrics = Metrics.getSharedInstance()
     metric = metrics.getMetric(name)
     if metric is None:
         metric = CounterMetric()
         metrics.addMetric(name, metric)
     metric.inc()
Пример #4
0
 def getMetric(self):
     band = "unknown"
     if self.band is not None:
         band = self.band.getName()
     name = "aprs.decodes.{band}.aprs".format(band=band)
     metrics = Metrics.getSharedInstance()
     metric = metrics.getMetric(name)
     if metric is None:
         metric = CounterMetric()
         metrics.addMetric(name, metric)
     return metric
Пример #5
0
 def __init__(self, maxsize, workers):
     super().__init__(maxsize)
     metrics = Metrics.getSharedInstance()
     metrics.addMetric("decoding.queue.length", DirectMetric(self.qsize))
     self.inCounter = CounterMetric()
     metrics.addMetric("decoding.queue.in", self.inCounter)
     self.outCounter = CounterMetric()
     metrics.addMetric("decoding.queue.out", self.outCounter)
     self.overflowCounter = CounterMetric()
     metrics.addMetric("decoding.queue.overflow", self.overflowCounter)
     self.errorCounter = CounterMetric()
     metrics.addMetric("decoding.queue.error", self.errorCounter)
     self.workers = [self.newWorker() for _ in range(0, workers)]
Пример #6
0
 def getMetric(self, category):
     if category not in self.metrics:
         band = "unknown"
         if self.band is not None:
             band = self.band.getName()
         name = "aprs.decodes.{band}.aprs.{category}".format(
             band=band, category=category)
         metrics = Metrics.getSharedInstance()
         self.metrics[category] = metrics.getMetric(name)
         if self.metrics[category] is None:
             self.metrics[category] = CounterMetric()
             metrics.addMetric(name, self.metrics[category])
     return self.metrics[category]
Пример #7
0
    def pushDecode(self, band):
        metrics = Metrics.getSharedInstance()
        bandName = "unknown"
        if band is not None:
            bandName = band.getName()

        name = "js8call.decodes.{band}.JS8".format(band=bandName)
        metric = metrics.getMetric(name)
        if metric is None:
            metric = CounterMetric()
            metrics.addMetric(name, metric)

        metric.inc()
Пример #8
0
    def pushDecode(self, mode, band):
        metrics = Metrics.getSharedInstance()
        bandName = "unknown"
        if band is not None:
            bandName = band.getName()

        if mode is None:
            mode = "unknown"

        name = "wsjt.decodes.{band}.{mode}".format(band=bandName, mode=mode)
        metric = metrics.getMetric(name)
        if metric is None:
            metric = CounterMetric()
            metrics.addMetric(name, metric)

        metric.inc()
Пример #9
0
 def __init__(self):
     pm = Config.get()
     super().__init__(pm["decoding_queue_length"])
     self.workers = []
     self._setWorkers(pm["decoding_queue_workers"])
     self.subscriptions = [
         pm.wireProperty("decoding_queue_length", self._setMaxSize),
         pm.wireProperty("decoding_queue_workers", self._setWorkers),
     ]
     metrics = Metrics.getSharedInstance()
     metrics.addMetric("decoding.queue.length", DirectMetric(self.qsize))
     self.inCounter = CounterMetric()
     metrics.addMetric("decoding.queue.in", self.inCounter)
     self.outCounter = CounterMetric()
     metrics.addMetric("decoding.queue.out", self.outCounter)
     self.overflowCounter = CounterMetric()
     metrics.addMetric("decoding.queue.overflow", self.overflowCounter)
     self.errorCounter = CounterMetric()
     metrics.addMetric("decoding.queue.error", self.errorCounter)
Пример #10
0
    def prometheusAction(self):
        metrics = Metrics.getSharedInstance().getFlatMetrics()

        def prometheusFormat(key, metric):
            value = metric.getValue()
            if isinstance(metric, CounterMetric):
                key += "_total"
                value = value["count"]
            elif isinstance(metric, DirectMetric):
                pass
            else:
                raise ValueError("Unexpected metric type for metric {}".format(
                    repr(metric)))

            return "{key} {value}".format(key=key.replace(".", "_"),
                                          value=value)

        data = [
            "# https://prometheus.io/docs/instrumenting/exposition_formats/"
        ] + [prometheusFormat(k, v) for k, v in metrics.items()]

        self.send_response("\n".join(data),
                           content_type="text/plain; version=0.0.4")
Пример #11
0
 def indexAction(self):
     data = json.dumps(Metrics.getSharedInstance().getHierarchicalMetrics())
     self.send_response(data, content_type="application/json")
Пример #12
0
 def __init__(self):
     self.clients = []
     Metrics.getSharedInstance().addMetric("openwebrx.users",
                                           DirectMetric(self.clientCount))
     super().__init__()