lib/barnes/periodic.rb in barnes-0.0.5 vs lib/barnes/periodic.rb in barnes-0.0.6
- old
+ new
@@ -26,14 +26,14 @@
module Barnes
# The periodic class is used to send occasional metrics
# to a reporting instance of `Barnes::Reporter` at a semi-regular
# rate.
class Periodic
- def initialize(reporter:, sample_rate: 1, panels: [])
+ def initialize(reporter:, sample_rate: 1, debug: false, panels: [])
@reporter = reporter
@reporter.sample_rate = sample_rate
-
+ @debug = debug
# compute interval based on a 60s reporting phase.
@interval = sample_rate * 60.0
@panels = panels
@thread = Thread.new {
@@ -55,9 +55,11 @@
}
@panels.each do |panel|
panel.instrument! env[STATE], env[COUNTERS], env[GAUGES]
end
+
+ puts env.to_json if @debug
@reporter.report env
end
end
}
@thread.abort_on_exception = true