class Gruf::Prometheus::Client::TypeCollector
Type Collector
for grpc client metrics
Public Instance Methods
type()
click to toggle source
# File lib/gruf/prometheus/client/type_collector.rb, line 25 def type 'grpc_client' end
Private Instance Methods
build_metrics()
click to toggle source
Initialize the collector
# File lib/gruf/prometheus/client/type_collector.rb, line 34 def build_metrics metrics = { grpc_client_started_total: PrometheusExporter::Metric::Counter.new('grpc_client_started_total', 'Total number of RPCs started by the client'), grpc_client_completed: PrometheusExporter::Metric::Counter.new('grpc_client_completed', 'Total number of RPCs completed by the client, regardless of success or failure') } metrics[:grpc_client_completed_latency_seconds] = PrometheusExporter::Metric::Histogram.new('grpc_client_completed_latency_seconds', 'Histogram of response latency of RPCs completed by the client, in seconds') if measure_latency? metrics end
collect_metrics(data: {}, labels: {})
click to toggle source
Collect the object into the buffer
# File lib/gruf/prometheus/client/type_collector.rb, line 46 def collect_metrics(data: {}, labels: {}) metric(:grpc_client_started_total)&.observe(data['grpc_client_started_total'].to_i, labels) metric(:grpc_client_completed)&.observe(data['grpc_client_completed'].to_i, labels) metric(:grpc_client_completed_latency_seconds)&.observe(data['grpc_client_completed_latency_seconds'].to_f, labels) if measure_latency? end
measure_latency?()
click to toggle source
@return [Boolean]
# File lib/gruf/prometheus/client/type_collector.rb, line 55 def measure_latency? @measure_latency ||= ::Gruf::Prometheus.client_measure_latency end