class Fluent::Plugin::NodeExporter::TimeMetricsCollector

Public Class Methods

new(config={}) click to toggle source
# File lib/fluent/plugin/node_exporter/time_collector.rb, line 24
def initialize(config={})
  super(config)

  @gauge = CMetrics::Gauge.new
  @gauge.create("node", "", "time_seconds",
                "System time in seconds since epoch (1970).")
end

Public Instance Methods

cmetrics() click to toggle source
# File lib/fluent/plugin/node_exporter/time_collector.rb, line 42
def cmetrics
  {
    time_seconds: @gauge
  }
end
run() click to toggle source
# File lib/fluent/plugin/node_exporter/time_collector.rb, line 32
def run
  time_update
end
time_update() click to toggle source
# File lib/fluent/plugin/node_exporter/time_collector.rb, line 36
def time_update
  current_time = Fluent::EventTime.now
  value = current_time.to_i / 1e9
  @gauge.set(value)
end