diff --git a/lib/datadog/statsd/forwarder.rb b/lib/datadog/statsd/forwarder.rb index dcbd53e..88624eb 100644 --- a/lib/datadog/statsd/forwarder.rb +++ b/lib/datadog/statsd/forwarder.rb @@ -25,11 +25,13 @@ def initialize( ) @transport_type = connection_cfg.transport_type - if telemetry_flush_interval - @telemetry = Telemetry.new(telemetry_flush_interval, + @telemetry = if telemetry_flush_interval + Telemetry.new(telemetry_flush_interval, global_tags: global_tags, transport_type: @transport_type ) + else + nil end @connection = connection_cfg.make_connection(logger: logger, telemetry: telemetry) diff --git a/lib/datadog/statsd/sender.rb b/lib/datadog/statsd/sender.rb index c317158..a5e863e 100644 --- a/lib/datadog/statsd/sender.rb +++ b/lib/datadog/statsd/sender.rb @@ -20,8 +20,10 @@ def initialize(message_buffer, telemetry: nil, queue_size: UDP_DEFAULT_BUFFER_SI @mx = Mutex.new @queue_class = queue_class @thread_class = thread_class - if flush_interval - @flush_timer = Datadog::Statsd::Timer.new(flush_interval) { flush(sync: true) } + @flush_timer = if flush_interval + Datadog::Statsd::Timer.new(flush_interval) { flush(sync: true) } + else + nil end end diff --git a/lib/datadog/statsd/timer.rb b/lib/datadog/statsd/timer.rb index 8c1c894..8eaed44 100644 --- a/lib/datadog/statsd/timer.rb +++ b/lib/datadog/statsd/timer.rb @@ -9,6 +9,7 @@ def initialize(interval, &callback) @interval = interval @callback = callback @stop = true + @thread = nil end def start diff --git a/spec/statsd/version_spec.rb b/spec/statsd/version_spec.rb index ce33748..a13ec3e 100644 --- a/spec/statsd/version_spec.rb +++ b/spec/statsd/version_spec.rb @@ -3,7 +3,7 @@ describe Datadog::Statsd do describe 'VERSION' do it 'has a version' do - expect(Datadog::Statsd::VERSION).to match /\d+\.\d+\.\d+/ + expect(Datadog::Statsd::VERSION).to match(/\d+\.\d+\.\d+/) end end end diff --git a/spec/statsd_spec.rb b/spec/statsd_spec.rb index 26b3689..1c659b2 100644 --- a/spec/statsd_spec.rb +++ b/spec/statsd_spec.rb @@ -1014,7 +1014,7 @@ it 'does not raise error' do expect do subject.event(title, text, options) - end.not_to raise_error(RuntimeError, /payload is too big/) + end.not_to raise_error end end end