Class: Sidekiq::Middleware::Datadog
- Inherits:
-
Object
- Object
- Sidekiq::Middleware::Datadog
- Defined in:
- lib/sidekiq/middleware/datadog.rb
Instance Attribute Summary collapse
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#statsd ⇒ Object
Returns the value of attribute statsd.
-
#statsd_host ⇒ Object
Returns the value of attribute statsd_host.
-
#statsd_port ⇒ Object
Returns the value of attribute statsd_port.
Instance Method Summary collapse
- #call(worker, job, queue) ⇒ Object
-
#initialize(opts) ⇒ Datadog
constructor
Configure and install datadog instrumentation.
Constructor Details
#initialize(opts) ⇒ Datadog
Configure and install datadog instrumentation. Example:
Sidekiq.configure_server do |config|
config.server_middleware do |chain|
chain.add Sidekiq::Middleware::Datadog
end
end
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sidekiq/middleware/datadog.rb', line 18 def initialize(opts) statsd_host = opts[:statsd_host] || "localhost" statsd_port = (opts[:statsd_port] || 8125).to_i prefix = opts[:prefix] || "" @metric_name = opts[:metric_name] || "worker" @statsd = opts[:statsd] || ::Datadog::Statsd.new(statsd_host, statsd_port, namespace: prefix) = opts[:tags] || [] () end |
Instance Attribute Details
#hostname ⇒ Object
Returns the value of attribute hostname.
8 9 10 |
# File 'lib/sidekiq/middleware/datadog.rb', line 8 def hostname @hostname end |
#statsd ⇒ Object
Returns the value of attribute statsd.
8 9 10 |
# File 'lib/sidekiq/middleware/datadog.rb', line 8 def statsd @statsd end |
#statsd_host ⇒ Object
Returns the value of attribute statsd_host.
8 9 10 |
# File 'lib/sidekiq/middleware/datadog.rb', line 8 def statsd_host @statsd_host end |
#statsd_port ⇒ Object
Returns the value of attribute statsd_port.
8 9 10 |
# File 'lib/sidekiq/middleware/datadog.rb', line 8 def statsd_port @statsd_port end |
Instance Method Details
#call(worker, job, queue) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sidekiq/middleware/datadog.rb', line 30 def call(worker, job, queue, *) start = Time.now begin yield record(worker, job, queue, start) rescue => e record(worker, job, queue, start, e) raise end end |