-
-
Save yorickpeterse/23e27d55256bfe4a53a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Shepherd | |
## | |
# Dirty class for sending Rubinius metrics to Insights at a given interval. | |
# | |
# @!attribute [r] sqs | |
# @return [AWS::SQS] | |
# | |
class RubiniusInsights | |
attr_reader :sqs | |
def initialize | |
@sqs = AWS::SQS.new | |
end | |
def start | |
loop do | |
metrics = Rubinius::Metrics.data.to_hash | |
payload = metrics.merge(:event => 'rubinius', :method => 'track') | |
queue.send_message(JSON.dump(payload)) | |
sleep(interval) | |
end | |
end | |
## | |
# @return [AWS::SQS::Queue] | |
# | |
def queue | |
return @queue ||= sqs.queues.named(queue_name) | |
end | |
## | |
# @return [String] | |
# | |
def queue_name | |
return ENV['TRACKERS_QUEUE'] | |
end | |
## | |
# @return [Fixnum] | |
# | |
def interval | |
env = ENV['METRICS_INSIGHTS_INTERVAL'] | |
return env ? env.to_i : 30 | |
end | |
end # RubiniusInsights | |
end # Shepherd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment