feat: add health server and prometheus metrics to worker

This commit is contained in:
Adam Cooke
2024-02-23 22:51:38 +00:00
committed by Adam Cooke
parent 1ae8ef6401
commit a2eb70edf1
7 changed files with 167 additions and 3 deletions
+23
View File
@@ -0,0 +1,23 @@
# frozen_string_literal: true
module HasPrometheusMetrics
def register_prometheus_counter(name, **kwargs)
counter = Prometheus::Client::Counter.new(name, **kwargs)
registry.register(counter)
end
def increment_prometheus_counter(name, labels: {})
counter = registry.get(name)
return if counter.nil?
counter.increment(labels: labels)
end
private
def registry
Prometheus::Client.registry
end
end