Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use process name in metric source

  • Loading branch information...
commit 409d6d563b44fd81f05b97c3b8f2d96299ca17d4 1 parent 2e807da
Larry Marburger authored

Showing 1 changed file with 7 additions and 2 deletions. Show diff stats Hide diff stats

  1. 9  lib/bundler_api/metriks.rb
9  lib/bundler_api/metriks.rb
@@ -5,13 +5,18 @@
5 5
 token = ENV['LIBRATO_METRICS_TOKEN']
6 6
 if user && token
7 7
   require 'metriks/reporter/librato_metrics'
8  
-  require 'socket'
9 8
 
10 9
   prefix = ENV.fetch('LIBRATO_METRICS_PREFIX') do
11 10
     ENV['RACK_ENV'] unless ENV['RACK_ENV'] == 'production'
12 11
   end
13 12
 
14  
-  source   = [ Socket.gethostname, Process.pid ].join('-')
  13
+  app_name = ENV.fetch('PS') do
  14
+    # Fall back to hostname if PS isn't set.
  15
+    require 'socket'
  16
+    Socket.gethostname
  17
+  end
  18
+
  19
+  source   = [ app_name, Process.pid ].join('-')
15 20
   on_error = ->(e) do STDOUT.puts("LibratoMetrics: #{ e.message }") end
16 21
   opts     = { on_error: on_error, source: source }
17 22
   opts[:prefix] = prefix if prefix && !prefix.empty?

0 notes on commit 409d6d5

Please sign in to comment.
Something went wrong with that request. Please try again.