Sha256: d819dd11be483866385f81c621b0a368bcdaefbfa14015b23ee32f3d24516b1c

Contents?: true

Size: 1.4 KB

Versions: 58

Compression:

Stored size: 1.4 KB

Contents

# encoding: utf-8
require "logstash/instrument/metric"

module LogStash module Instrument
  # This class acts a a proxy between the metric library and the user calls.
  #
  # This is the class that plugins authors will use to interact with the `MetricStore`
  # It has the same public interface as `Metric` class but doesnt require to send
  # the namespace on every call.
  #
  # @see Logstash::Instrument::Metric
  class NamespacedMetric
    attr_reader :namespace_name
    # Create metric with a specific namespace
    #
    # @param metric [LogStash::Instrument::Metric] The metric instance to proxy
    # @param namespace [Array] The namespace to use
    def initialize(metric, namespace_name)
      @metric = metric
      @namespace_name = Array(namespace_name)
    end

    def increment(key, value = 1)
      @metric.increment(namespace_name, key, value)
    end

    def decrement(key, value = 1)
      @metric.decrement(namespace_name, key, value)
    end

    def gauge(key, value)
      @metric.gauge(namespace_name, key, value)
    end

    def report_time(key, duration)
      @metric.report_time(namespace_name, key, duration)
    end

    def time(key, &block)
      @metric.time(namespace_name, key, &block)
    end

    def collector
      @metric.collector
    end

    def namespace(name)
      NamespacedMetric.new(metric, namespace_name + Array(name))
    end

    private
    attr_reader :metric
  end
end; end

Version data entries

58 entries across 57 versions & 11 rubygems

Version Path
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.3.0/gems/logstash-core-5.2.1-java/lib/logstash/instrument/namespaced_metric.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.3.0/gems/logstash-core-5.2.1-java/lib/logstash/instrument/namespaced_metric.rb
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/logstash-core-5.0.0-java/lib/logstash/instrument/namespaced_metric.rb
logstash-output-icinga-1.1.0 vendor/jruby/2.3.0/gems/logstash-core-5.2.1-java/lib/logstash/instrument/namespaced_metric.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/logstash-core-5.2.1-java/lib/logstash/instrument/namespaced_metric.rb
logstash-core-5.5.3-java lib/logstash/instrument/namespaced_metric.rb
logstash-core-5.5.2-java lib/logstash/instrument/namespaced_metric.rb
logstash-core-6.0.0.beta1-java lib/logstash/instrument/namespaced_metric.rb
logstash-core-5.5.1-java lib/logstash/instrument/namespaced_metric.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/logstash-core-5.5.1.snapshot1-java/lib/logstash/instrument/namespaced_metric.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/logstash-core-5.5.1.snapshot1-java/lib/logstash/instrument/namespaced_metric.rb
logstash-core-5.5.1.snapshot1-java lib/logstash/instrument/namespaced_metric.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/logstash-core-5.5.0-java/lib/logstash/instrument/namespaced_metric.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/logstash-core-5.4.0-java/lib/logstash/instrument/namespaced_metric.rb
logstash-core-5.5.0-java lib/logstash/instrument/namespaced_metric.rb
logstash-core-5.4.3-java lib/logstash/instrument/namespaced_metric.rb
logstash-core-5.4.2-java lib/logstash/instrument/namespaced_metric.rb
logstash-filter-csharp-0.1.0 vendor/bundle/jruby/2.3.0/gems/logstash-core-5.2.1-java/lib/logstash/instrument/namespaced_metric.rb
logstash-core-6.0.0.alpha2-java lib/logstash/instrument/namespaced_metric.rb
logstash-core-5.4.1-java lib/logstash/instrument/namespaced_metric.rb