sashgorokhov / scrapy_prometheus

Exporting scrapy stats as prometheus metrics through pushgateway service
MIT License
6 stars 6 forks source link

Fix scraping metrics #2

Open danihodovic opened 3 years ago

danihodovic commented 3 years ago

Two patches:

  1. If labels are None prometheus_client throws the following error

    
    cls = prometheus_client.metrics.Counter(scrapy_prometheus_log_count_INFO), labelnames = None
    
    def _validate_labelnames(cls, labelnames):
    >       labelnames = tuple(labelnames)
    E       TypeError: 'NoneType' object is not iterable

.venv/lib/python3.8/site-packages/prometheus_client/metrics.py:40: TypeError



Initialize them to an empty dict as a workaround.

2. If we try to create a metric that already exists catch the error
   detailing duplicate timeseries and supress it. Raise any other
   exception.