Sha256: f953c4039074c0d9f6f6bf8e5bc0641dceb9922ff36595d1c9684c61346dcacf
Contents?: true
Size: 1.1 KB
Versions: 5
Compression:
Stored size: 1.1 KB
Contents
require 'liquid/logger' require_relative './metrics-core-3.0.1.jar' java_import 'com.codahale.metrics.Histogram' java_import 'com.codahale.metrics.JmxReporter' java_import 'com.codahale.metrics.MetricRegistry' java_import 'java.util.concurrent.TimeUnit' class Histogram java_alias :update_long, :update, [Java::long] end module Metrics @registry = MetricRegistry.new @reporters = [] def self.start(period = nil, unit = nil) @period ||= 60 @unit ||= TimeUnit::SECONDS JmxReporter.forRegistry(@registry).build.start Signal.register_shutdown_handler { stop } end def self.stop @reporters.each do |reporter| reporter.run if reporter.respond_to?(:run) reporter.stop end @reporters.clear end def self.register_reporter(reporter) reporter.start(@period, @unit) @reporters << reporter end def self.registry @registry end def self.counter(name) registry.counter(name) end def self.meter(name) registry.meter(name) end def self.histogram(name) registry.histogram(name) end def self.timer(name) registry.timer(name) end end
Version data entries
5 entries across 5 versions & 1 rubygems