module Fluent::GcloudPubSub::Metrics
Utilities for interacting with Prometheus metrics
Public Class Methods
measure_duration() { || ... }
click to toggle source
Time the elapsed execution of the provided block, return the duration as the first element followed by the result of the block.
# File lib/fluent/plugin/gcloud_pubsub/metrics.rb, line 15 def self.measure_duration start = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = yield finish = Process.clock_gettime(Process::CLOCK_MONOTONIC) [finish - start, *result] end
register_or_existing(metric_name) { || ... }
click to toggle source
# File lib/fluent/plugin/gcloud_pubsub/metrics.rb, line 7 def self.register_or_existing(metric_name) return ::Prometheus::Client.registry.get(metric_name) if ::Prometheus::Client.registry.exist?(metric_name) yield end