danihodovic / celery-exporter

A Prometheus exporter for Celery metrics
MIT License
385 stars 85 forks source link

Add celery_worker_last_heartbeat_timestamp gauge #229

Closed roganartu closed 1 year ago

roganartu commented 1 year ago

Implements #228.

I tested this manually and it seems to work as expected:

❯ for i in {1..10}; do curl "http://localhost:9808/metrics" -sL | rg last_heartbeat_timestamp | rg -v '^#'; done
celery_worker_last_heartbeat_timestamp{hostname="2f17101080ee"} 1.6771803171352026e+09
celery_worker_last_heartbeat_timestamp{hostname="2f17101080ee"} 1.6771803191380432e+09
celery_worker_last_heartbeat_timestamp{hostname="2f17101080ee"} 1.677180321139897e+09
celery_worker_last_heartbeat_timestamp{hostname="2f17101080ee"} 1.677180321139897e+09
celery_worker_last_heartbeat_timestamp{hostname="2f17101080ee"} 1.677180323141491e+09
celery_worker_last_heartbeat_timestamp{hostname="2f17101080ee"} 1.6771803251429496e+09
celery_worker_last_heartbeat_timestamp{hostname="2f17101080ee"} 1.6771803271442914e+09
celery_worker_last_heartbeat_timestamp{hostname="2f17101080ee"} 1.6771803291466177e+09
celery_worker_last_heartbeat_timestamp{hostname="2f17101080ee"} 1.6771803311494062e+09
celery_worker_last_heartbeat_timestamp{hostname="2f17101080ee"} 1.6771803331514475e+09

I cannot get the test I added to pass locally with the redis or rabbitmq brokers, however. I think it's something to do with my test setup, but it always fails at the is not None assertion, as (no matter how long the sleep is) there's never any samples. It passes fine with the memory broker.

roganartu commented 1 year ago

Abandoning as #235 fixed in a different way.