Skip to content

Gem for transmitting data to Radar

Notifications You must be signed in to change notification settings

purpleworkshops/acars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Acars

Makes it easier to transmit StatsD-like metrics to Radar.

  • You MUST define an environment variable named ACARS_KEY that 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 heartbeat is reserved for monitoring your application's "health" status. Send a 1 to indicate that your application is flying normally, or 0 to send a mayday call.

Installation

Add this line to the application's Gemfile:

gem 'acars', git: 'https://github.com/purpleworkshops/acars'

Usage

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
end

Or 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
end

Dry Run mode

You 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

About

Gem for transmitting data to Radar

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published