lib/prometheus/client/push.rb in prometheus-client-0.4.0 vs lib/prometheus/client/push.rb in prometheus-client-0.4.1

- old
+ new

@@ -26,19 +26,15 @@ @path = build_path(job, instance) @http = Net::HTTP.new(@uri.host, @uri.port) end def add(registry) - data = Formats::Text.marshal(registry) - - @http.send_request('PUT', path, data, HEADER) + request('POST', registry) end def replace(registry) - @http.send_request('DELETE', path) - - add(registry) + request('PUT', registry) end private def parse(url) @@ -57,9 +53,15 @@ if instance format(INSTANCE_PATH, URI.escape(job), URI.escape(instance)) else format(PATH, URI.escape(job)) end + end + + def request(method, registry) + data = Formats::Text.marshal(registry) + + @http.send_request(method, path, data, HEADER) end end end end