Class: Bigcommerce::Prometheus::Servers::Thin::ServerMetrics
- Inherits:
-
Object
- Object
- Bigcommerce::Prometheus::Servers::Thin::ServerMetrics
- Defined in:
- lib/bigcommerce/prometheus/servers/thin/server_metrics.rb
Overview
Server metrics for the collector
Instance Method Summary collapse
- #add_bad_metric ⇒ Object
- #add_metric ⇒ Object
- #add_session ⇒ Object
-
#initialize(logger: nil) ⇒ ServerMetrics
constructor
A new instance of ServerMetrics.
- #to_prometheus_text(working: true) ⇒ String
Constructor Details
#initialize(logger: nil) ⇒ ServerMetrics
Returns a new instance of ServerMetrics.
33 34 35 36 37 38 39 40 |
# File 'lib/bigcommerce/prometheus/servers/thin/server_metrics.rb', line 33 def initialize(logger: nil) @logger = logger || ::Bigcommerce::Prometheus.logger @metrics_total = ::PrometheusExporter::Metric::Counter.new('collector_metrics_total', 'Total metrics processed by exporter.') @sessions_total = ::PrometheusExporter::Metric::Counter.new('collector_sessions_total', 'Total send_metric sessions processed by exporter.') @bad_metrics_total = ::PrometheusExporter::Metric::Counter.new('collector_bad_metrics_total', 'Total mis-handled metrics by collector.') @collector_working_gauge = ::PrometheusExporter::Metric::Gauge.new('collector_working', 'Is the main process collector able to collect metrics') @collector_rss_gauge = ::PrometheusExporter::Metric::Gauge.new('collector_rss', 'total memory used by collector process') end |
Instance Method Details
#add_bad_metric ⇒ Object
50 51 52 |
# File 'lib/bigcommerce/prometheus/servers/thin/server_metrics.rb', line 50 def add_bad_metric @bad_metrics_total.observe end |
#add_metric ⇒ Object
46 47 48 |
# File 'lib/bigcommerce/prometheus/servers/thin/server_metrics.rb', line 46 def add_metric @metrics_total.observe end |
#add_session ⇒ Object
42 43 44 |
# File 'lib/bigcommerce/prometheus/servers/thin/server_metrics.rb', line 42 def add_session @sessions_total.observe end |
#to_prometheus_text(working: true) ⇒ String
58 59 60 |
# File 'lib/bigcommerce/prometheus/servers/thin/server_metrics.rb', line 58 def to_prometheus_text(working: true) collect(working: working).map(&:to_prometheus_text).join("\n\n") end |