Permalink
Browse files

Use process name in metric source

  • Loading branch information...
1 parent 2e807da commit 409d6d563b44fd81f05b97c3b8f2d96299ca17d4 @lmarburger lmarburger committed Mar 15, 2013
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/bundler_api/metriks.rb
@@ -5,13 +5,18 @@
token = ENV['LIBRATO_METRICS_TOKEN']
if user && token
require 'metriks/reporter/librato_metrics'
- require 'socket'
prefix = ENV.fetch('LIBRATO_METRICS_PREFIX') do
ENV['RACK_ENV'] unless ENV['RACK_ENV'] == 'production'
end
- source = [ Socket.gethostname, Process.pid ].join('-')
+ app_name = ENV.fetch('PS') do
+ # Fall back to hostname if PS isn't set.
+ require 'socket'
+ Socket.gethostname
+ end
+
+ source = [ app_name, Process.pid ].join('-')
on_error = ->(e) do STDOUT.puts("LibratoMetrics: #{ e.message }") end
opts = { on_error: on_error, source: source }
opts[:prefix] = prefix if prefix && !prefix.empty?

0 comments on commit 409d6d5

Please sign in to comment.