Makes it easier to transmit StatsD-like metrics to Radar.
- You MUST define an environment variable named
ACARS_KEYthat holds your secret API key for Radar. Ask Jeff for your API key. - At the moment, this gem only supports transmitting "gauge"-style metrics.
- The special gauge name
heartbeatis reserved for monitoring your application's "health" status. Send a1to indicate that your application is flying normally, or0to send a mayday call.
Add this line to the application's Gemfile:
gem 'acars', git: 'https://github.com/purpleworkshops/acars'For this example, assume your app name is "research_study".
Here is a sample rake task (but also see the Dry Run example below)
desc "Transmit stats"
task acars: :environment do
Acars.transmit_for :research_study do |acars|
acars.gauge participants: Participant.count,
events: AppEvent.count,
messages: Message.count,
heartbeat: (AppEvent.order(created_at: :desc).first.created_at > 1.hour.ago ? 1 : 0)
end
endOr if you prefer to make separate calls:
desc "Transmit stats"
task acars: :environment do
Acars.transmit_for :research_study do |acars|
acars.gauge participants: Participant.count
acars.gauge events: AppEvent.count
acars.gauge messages: Message.count
acars.gauge heartbeat: (AppEvent.order(created_at: :desc).first.created_at > 1.hour.ago ? 1 : 0)
end
endYou can also pass a dry_run: true argument to prevent Acars from actually transmitting data.
For example, this will only transmit stats in production, and emit to stdout otherwise:
Acars.transmit_for :research_study, dry_run: (!Rails.env.production?) do |acars|
...
end