Sha256: 36229c079dff83b6359244e3888d7b27032f58ab2c29d31452cbfdde543a204d

Contents?: true

Size: 1.19 KB

Versions: 107

Compression:

Stored size: 1.19 KB

Contents

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

describe LogStash::Instrument::PeriodicPoller::Base do
  let(:metric) { LogStash::Instrument::Metric.new(LogStash::Instrument::Collector.new) }
  let(:options) { {} }

  subject { described_class.new(metric, options) }

  describe "#update" do
    it "logs an timeout exception to debug level" do
      exception = Concurrent::TimeoutError.new
      expect(subject.logger).to receive(:debug).with(anything, hash_including(:exception => exception.class))
      subject.update(Time.now, "hola", exception)
    end

    it "logs any other exception to error level" do
      exception = Class.new
      expect(subject.logger).to receive(:error).with(anything, hash_including(:exception => exception.class))
      subject.update(Time.now, "hola", exception)
    end

    it "doesnt log anything when no exception is received" do
      exception = Concurrent::TimeoutError.new
      expect(subject.logger).not_to receive(:debug).with(anything)
      expect(subject.logger).not_to receive(:error).with(anything)
      subject.update(Time.now, "hola", exception)
    end
  end
end

Version data entries

107 entries across 104 versions & 11 rubygems

Version Path
logstash-core-6.0.0-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-core-5.6.4-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-core-6.0.0.rc2-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-core-5.6.3-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/logstash-core-5.2.1-java/spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-output-icinga-1.1.0 vendor/jruby/2.3.0/gems/logstash-core-5.2.1-java/spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-core-6.0.0.rc1-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-core-5.6.2-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-core-5.6.1-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-core-5.5.3-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-core-5.6.0-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-core-6.0.0.beta2-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-core-5.5.2-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-core-6.0.0.beta1-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-core-5.5.1-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/logstash-core-5.5.1.snapshot1-java/spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/logstash-core-5.5.1.snapshot1-java/spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-core-5.5.1.snapshot1-java spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/logstash-core-5.5.0-java/spec/logstash/instrument/periodic_poller/base_spec.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/logstash-core-5.4.0-java/spec/logstash/instrument/periodic_poller/base_spec.rb