Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--stats-processor #20

Open
mmb opened this issue Sep 7, 2017 · 1 comment
Open

--stats-processor #20

mmb opened this issue Sep 7, 2017 · 1 comment

Comments

@mmb
Copy link

mmb commented Sep 7, 2017

How is --stats-processor meant to be used?

I can't find anything in the code that calls it. Could this be used to send data to statsd?

@tompesman
Copy link
Member

I've only used this feature with Librato, but you can rewrite it to use statsd I think.

call pushr with bundle exec pushr -f -s "lib/pushr/stats_processor"

require 'librato/metrics'
require_relative 'metrics'

module Pushr
  class StatsProcessor
    # name, start, finish, id, payload
    def call(_, start, finish, _, payload)
      messagetype = payload[:type]['Pushr::Message'.size, payload[:type].size].downcase
      hsh = { measure_time: Time.now, value: ((finish - start) * 1000) }
      Pushr::Metrics.queue.add "#{payload[:app]}:message:#{messagetype}:time" => hsh
    end
  end
end

Librato::Metrics.authenticate ENV['LIBRATO_EMAIL'], ENV['LIBRATO_KEY']
Pushr::Metrics.queue_constructor = Librato::Metrics::Queue.method(:new)
Pushr::Metrics.logger            = ::Pushr::Daemon.logger
Pushr::Metrics.exception_handler = ::Airbrake.method(:notify) if defined?(::Airbrake)

ActiveSupport::Notifications.subscribe('message', Pushr::StatsProcessor.new)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants