Port of Dropwizard Metrics-Core

Gem Version Build Status Dependency Status Code Climate Coverage Status Issue Count

This is literal port of http://metrics.dropwizard.io/3.1.0/. as the naming convention of Java is slightly different some internal variable names still following the Java naming convention. all public method names are using Ruby naming conventions.

There are also serveral parts missing, they are easy to add to contributions here are welcome.

Most work was only possible to excelant concurrency-ruby gem which allows to copy most concurrency semantic one to one over to ruby. This gem really made the port a copy and paste and then find and replace job.

State of the Code

Currently no Reporters are there. once they are in place things are ready to be used.

Rubygems/Bundler

gem install leafy

or Gemfile:

gem 'leafy'

Getting Started

registry = Leafy::Core::MetricRegistry.new
meter = registry.meter('throughput')

reporter = Leafy::Core::ConsoleReporter::Builder.for_registry(registry) do
  output_to STDERR
  shutdown_executor_on_stop true
end
reporter.start(0, 10) # no initial_delay, report any 10 seconds

meter.mark(10)

use irb -rleafy/core/metric_registry -rleafy/core/console_reporter to start irb and copy and paste above code snippet.

Note on spawning processes

registry = Leafy::Core::MetricRegistry.new
meter = registry.meter('throughput')

Process.fork do
  reporter = Leafy::Core::ConsoleReporter::Builder.for_registry(registry) do
    output_to STDOUT
    shutdown_executor_on_stop true
  end
  reporter.start(0, 10) # no initial_delay, report any 10 seconds
  while true; end
end

meter.mark(10)

Here the reporter runs in different process and can not see the values on the meter changed by main process.

See Puma cluster config for an example configuration of puma.

Misssing Bits from Dropwizard

Gauge

none of the is done.

Reservoir

only the SlidingWindowReservoir and its UniformSnapshot is implemented.

MetricRegistry

  • no listeners
  • no MetricSet
  • no MetricFilters on collection methods
  • no customer builder via Supplier
  • no Gauge factory methods

Contributing

Bug reports and pull requests are welcome.

Alternative Libraries

Meta-Foo

be happy and enjoy.