R
R
Roman Mirilaczvili2021-10-06 15:51:51
Ruby on Rails
Roman Mirilaczvili, 2021-10-06 15:51:51

Why aren't metrics sent from Resque tasks?

The situation is such that metrics are sent at the start of the application, but not from tasks.

Trial metric:

DATADOG_CLIENT.increment('bbb', by: 1, tags: ['step:foo'])


At the same time , it app_boot.countis visible on the Datadog charts.

The project uses the following configuration:
config/initializers/datadog.rb

unless Rails.env.test? || ENV['DISABLE_DATADOG'].present?
  require 'datadog/statsd'

  if Rails.env.development?
    Datadog.configure do |c|
      c.use :rails, service_name: "#{`whoami`}-rails-app"
    end
  else
    Datadog.configure do |c|
      c.use :rails, service_name: "#{Rails.env}-rails-app"
      c.use :resque, { service_name: 'resque' }
    end
  end
  # Create a DogStatsD client instance.
  DATADOG_CLIENT = Datadog::Statsd.new('localhost', 8125)

  DATADOG_CLIENT.increment('app_boot.count', tags: ["env:#{Rails.env}"])

  at_exit do
    # release resources used by the client instance
    DATADOG_CLIENT.close()
  end
end


Gems:
ddtrace (0.49.0)
dogstatsd-ruby (5.0.1)

Need to be configured differently?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2021-10-07
@2ord

The gem developer advised:
1. update dogstatsd-ruby to version 5.3.0
2. add the optionsingle_thread: true

DATADOG_CLIENT = Datadog::Statsd.new('localhost', 8125, single_thread: true)

which solved the problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question