heroku-unicorn-metrics 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -10,11 +10,11 @@ First, add `heroku-unicorn-metrics` to your Gemfile:
10
10
  gem 'heroku-unicorn-metrics'
11
11
  ```
12
12
 
13
- Then subscribe to the `unicorn.metrics.request` notifcation in your Rails app. For example, to print queue information to your logs, add the following to `config/initializers/notifcations.rb:
13
+ Then subscribe to the `unicorn.metrics.queue` notifcation in your Rails app. For example, to print queue information to your logs, add the following to `config/initializers/notifcations.rb:
14
14
 
15
15
  ```
16
16
  # config/initializers/notifications.rb
17
- ActiveSupport::Notifications.subscribe(/unicorn.metrics.request/) do |*args|
17
+ ActiveSupport::Notifications.subscribe(/unicorn.metrics.queue/) do |*args|
18
18
  event = ActiveSupport::Notifications::Event.new(*args)
19
19
  payload = event.payload
20
20
 
@@ -3,19 +3,20 @@ require 'socket'
3
3
  module Heroku
4
4
  module UnicornMetrics
5
5
  class Queue
6
- ADDR = IPSocket.getaddress(Socket.gethostname).to_s+':'+ENV['PORT']
7
-
6
+
8
7
  def initialize(app)
9
8
  @app = app
10
9
  end
11
10
 
12
11
  def call(env)
12
+ return @app.call(env) unless ENV['PORT']
13
+
13
14
  start_time = Time.now.to_f*1000.0
14
15
  stats = raindrops_stats
15
16
 
16
17
  status, headers, body = @app.call(env)
17
18
 
18
- stats[:addr] = ADDR
19
+ stats[:addr] = IPSocket.getaddress(Socket.gethostname).to_s + ':'+ENV['PORT']
19
20
  stats[:queue_time] = headers['X-Request-Start'] ? (start_time - headers['X-Request-Start'].to_f).round : 0
20
21
 
21
22
  ActiveSupport::Notifications.instrument("unicorn.metrics.queue", stats)
@@ -1,5 +1,5 @@
1
1
  module Heroku
2
2
  module UnicornMetrics
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-unicorn-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: