Module: Sidekiq::Datadog::Monitor
- Defined in:
- lib/sidekiq/datadog/monitor.rb,
lib/sidekiq/datadog/monitor/version.rb,
lib/sidekiq/datadog/monitor/tag_builder.rb,
lib/sidekiq/datadog/monitor/metrics_sender.rb,
lib/sidekiq/datadog/monitor/heartbeat_patch.rb
Defined Under Namespace
Modules: HeartbeatPatch Classes: Error, MetricsSender, TagBuilder
Constant Summary collapse
- VERSION =
'1.1.1'.freeze
Class Attribute Summary collapse
-
.agent_host ⇒ Object
Returns the value of attribute agent_host.
-
.agent_port ⇒ Object
Returns the value of attribute agent_port.
-
.sender ⇒ Object
Returns the value of attribute sender.
-
.statsd ⇒ Object
Returns the value of attribute statsd.
-
.tags_builder ⇒ Object
Returns the value of attribute tags_builder.
Class Method Summary collapse
- .configure!(options) ⇒ Object
- .configured? ⇒ Boolean
- .initialize! ⇒ Object
- .send_metrics ⇒ Object
- .shutdown! ⇒ Object
Class Attribute Details
.agent_host ⇒ Object
Returns the value of attribute agent_host.
13 14 15 |
# File 'lib/sidekiq/datadog/monitor.rb', line 13 def agent_host @agent_host end |
.agent_port ⇒ Object
Returns the value of attribute agent_port.
13 14 15 |
# File 'lib/sidekiq/datadog/monitor.rb', line 13 def agent_port @agent_port end |
.sender ⇒ Object
Returns the value of attribute sender.
13 14 15 |
# File 'lib/sidekiq/datadog/monitor.rb', line 13 def sender @sender end |
.statsd ⇒ Object
Returns the value of attribute statsd.
13 14 15 |
# File 'lib/sidekiq/datadog/monitor.rb', line 13 def statsd @statsd end |
.tags_builder ⇒ Object
Returns the value of attribute tags_builder.
13 14 15 |
# File 'lib/sidekiq/datadog/monitor.rb', line 13 def @tags_builder end |
Class Method Details
.configure!(options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sidekiq/datadog/monitor.rb', line 15 def configure!() raise Sidekiq::Datadog::Monitor::Error, "Can't configure two times" if configured? @agent_host, @agent_port = .fetch_values(:agent_host, :agent_port) @tags_builder = Sidekiq::Datadog::Monitor::TagBuilder.new([:tags] || []) add_sidekiq_listeners rescue KeyError => e raise Sidekiq::Datadog::Monitor::Error, "Required param is missing: #{e.}" end |
.configured? ⇒ Boolean
26 27 28 |
# File 'lib/sidekiq/datadog/monitor.rb', line 26 def configured? agent_host && agent_port end |
.initialize! ⇒ Object
30 31 32 33 |
# File 'lib/sidekiq/datadog/monitor.rb', line 30 def initialize! @statsd = ::Datadog::Statsd.new(agent_host, agent_port) @sender = Sidekiq::Datadog::Monitor::MetricsSender.new(statsd, ) end |
.send_metrics ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/sidekiq/datadog/monitor.rb', line 35 def send_metrics sender&.send_metrics rescue ArgumentError => e # Ignore this error. Sometimes sender hasn't yet started when we send metrics for the first time on boot return if sender && e. == 'Start sender first' raise end |
.shutdown! ⇒ Object
44 45 46 47 |
# File 'lib/sidekiq/datadog/monitor.rb', line 44 def shutdown! @sender = nil # Remove sender first so beat event after shutdown does not raising error statsd.close end |