lib/gruf/prometheus/hook.rb
##
# Startup the instrumentors for collection of gRPC and process metrics prior to server start
#
# @param [Gruf::Server] server
#
Startup the instrumentors for collection of gRPC and process metrics prior to server start
Startup the instrumentors for collection of gRPC and process metrics prior to server start
def before_server_start(server:)
        logger.info "[gruf-prometheus][#{::Gruf::Prometheus.process_name}] Starting #{server.class}"
        prometheus_server.add_type_collector(::Gruf::Prometheus::TypeCollector.new)
        prometheus_server.add_type_collector(::Gruf::Prometheus::Server::TypeCollector.new)
        prometheus_server.add_type_collector(::Gruf::Prometheus::Client::TypeCollector.new)
        prometheus_server.add_type_collector(::PrometheusExporter::Server::ActiveRecordCollector.new)
        custom_type_collectors.each do |tc|
          prometheus_server.add_type_collector(tc)
        end
        prometheus_server.start
        sleep 2 unless ENV['RACK_ENV'] == 'test' 
        start_collectors(server: server)
      rescue StandardError => e
        logger.error "[gruf-prometheus][#{::Gruf::Prometheus.process_name}] Failed to start gruf instrumentation - #{e.message} - #{e.backtrace[0..4].join("\n")}"
      end
def before_server_start ( server : ) logger . info "[gruf-prometheus][#{::Gruf::Prometheus.process_name}] Starting #{server.class}" prometheus_server . add_type_collector ( :: Gruf :: Prometheus :: TypeCollector . new ) prometheus_server . add_type_collector ( :: Gruf :: Prometheus :: Server :: TypeCollector . new ) prometheus_server . add_type_collector ( :: Gruf :: Prometheus :: Client :: TypeCollector . new ) prometheus_server . add_type_collector ( :: PrometheusExporter :: Server :: ActiveRecordCollector . new ) custom_type_collectors . each do | tc | prometheus_server . add_type_collector ( tc ) end prometheus_server . start sleep 2 unless ENV [ 'RACK_ENV' ] == 'test' start_collectors ( server : server ) rescue StandardError => e logger . error "[gruf-prometheus][#{::Gruf::Prometheus.process_name}] Failed to start gruf instrumentation - #{e.message} - #{e.backtrace[0..4].join("\n")}" end
Startup the instrumentors for collection of gRPC and process metrics prior to server start
Startup the instrumentors for collection of gRPC and process metrics prior to server start
# wait for server to come online
server
<not_specific>
<not_specific>
None