Sha256: 9154087be25befd6371f24dcb1226326642ece7fbb43db7688bc313a91248afd

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'metrics-java'
require 'metrics-java/base_mixin'

module MetricsJ
  module Meter
    java_import 'java.util.concurrent.TimeUnit'
    java_import 'com.yammer.metrics.Metrics'

    def self.extended(base)
      base.instance_exec {
        extend  MetricsJ::BaseMixin
        include MetricsJ::Meter::InstanceMethods
      }
    end

    # @param [Symbol, String] meter_name The name of the meter
    # @return [com.yammer.metrics.core.MetricName] The MetricName that describes where the Metric data lives in JMX
    # @see MetricsJ.create_metric_name
    def meter(meter_name)
      scoped_name = "#{meter_name}_meter"
      metric_name = MetricsJ.create_metric_name(metric_group, metric_type, meter_name.to_s)

      new_meter = Metrics.new_meter(metric_name, meter_name.to_s, MetricsJ.time_unit_seconds)

      define_method(scoped_name) { new_meter }

      new_meter
    end

    def meters(*meter_names)
      meter_names.map!{ |meter_name| meter(meter_name) }
    end

    module InstanceMethods
      # @todo
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
metrics-java-0.0.1 lib/metrics-java/meter.rb