rack-honeycomb 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb430ad6e4cfc6990e23f4c8e532ac84564b2e280ca402d9396c44cce0e3959c
4
- data.tar.gz: ac15988e41bc4a15fd2f9d185825f4db38da5f800a7d90a2f3beb16272e2949f
3
+ metadata.gz: ef7c4729ce175288104850f4fe2202cf8cb51efa5b65b6e2cb4083df152c9368
4
+ data.tar.gz: 53be46494b255ff4bc3fed40ef1d6e7a2bd529238dcca359098d06671c16a759
5
5
  SHA512:
6
- metadata.gz: a990c747ca3624d37c6e3392b1398d7e53bb2340f222bf1f3394207e7c961fd1be41ab71555e5675c81e3246cc2597685e727ad3cb512dc7e394ce614818b309
7
- data.tar.gz: 303c79ad7ea9a38716ac4e8610cd9c69c87b95554ab4fe1972473e2137701a81a65958a7db8f5fb43f526d0c180e5c659f136cae9215bf364ab2bedf58be8c2d
6
+ metadata.gz: f710981f56110b49ebec88e178255c63d330bdedb2a97a7133eacc5cebd6912259b9318828f277017d51254dee23362acbbde803b70b1645524ede3d3bad7c79
7
+ data.tar.gz: 7041b6dbec9a01c3a0e18c0885fd7d4c1b85238768af9c6c088d1be436d986b00af0b9716ed00a008450c47a35fbeff091e9c0cf712bcf9df25aa7dcfc55d09f
@@ -5,7 +5,9 @@ module Rack
5
5
  class << self
6
6
  def available?(logger: nil)
7
7
  gem 'rack'
8
+ logger.debug "#{self.name}: detected rack" if logger
8
9
  gem 'sinatra'
10
+ logger.debug "#{self.name}: detected sinatra, okay to autoinitialise" if logger
9
11
  true
10
12
  rescue Gem::LoadError => e
11
13
  if e.name == 'sinatra'
@@ -26,7 +28,9 @@ module Rack
26
28
 
27
29
  ::Sinatra::Base.define_singleton_method(:build) do |*args, &block|
28
30
  if !AutoInstall.already_added
29
- self.use Rack::Honeycomb::Middleware, client: honeycomb_client
31
+ logger.debug "Adding Rack::Honeycomb::Middleware to #{self}" if logger
32
+
33
+ self.use Rack::Honeycomb::Middleware, client: honeycomb_client, logger: logger
30
34
  AutoInstall.already_added = true
31
35
  else
32
36
  # In the case of nested Sinatra apps - apps composed of other apps
@@ -35,9 +39,8 @@ module Rack
35
39
  # each child app. In that case, it's hard to hook in our
36
40
  # middleware reliably - so instead, we just want to warn the user
37
41
  # and avoid doing anything silly.
38
-
39
42
  unless AutoInstall.already_warned
40
- warn "Honeycomb auto-instrumentation of Sinatra will probably not work, try manual installation"
43
+ logger.warn "Honeycomb auto-instrumentation of Sinatra will probably not work, try manual installation" if logger
41
44
  AutoInstall.already_warned = true
42
45
  end
43
46
  end
@@ -29,11 +29,17 @@ module Rack
29
29
  def initialize(app, options = {})
30
30
  @app, @options = app, options
31
31
 
32
+ @logger = options.delete(:logger)
33
+ @logger ||= ::Honeycomb.logger if defined?(::Honeycomb.logger)
34
+
32
35
  honeycomb = if client = options.delete(:client)
36
+ debug "initialized with #{client.class.name} via :client option"
33
37
  client
34
38
  elsif defined?(::Honeycomb.client)
39
+ debug "initialized with #{::Honeycomb.client.class.name} from honeycomb-beeline"
35
40
  ::Honeycomb.client
36
41
  else
42
+ debug "initializing new Libhoney::Client"
37
43
  Libhoney::Client.new(options.merge(user_agent_addition: USER_AGENT_SUFFIX))
38
44
  end
39
45
  @builder = honeycomb.builder.
@@ -41,7 +47,7 @@ module Rack
41
47
  'meta.package' => 'rack',
42
48
  'meta.package_version' => RACK_VERSION,
43
49
  'type' => EVENT_TYPE,
44
- 'local_hostname' => Socket.gethostname,
50
+ 'meta.local_hostname' => Socket.gethostname,
45
51
  )
46
52
 
47
53
  @service_name = options.delete(:service_name) || :rack
@@ -78,6 +84,10 @@ module Rack
78
84
  end
79
85
 
80
86
  private
87
+ def debug(msg)
88
+ @logger.debug("#{self.class.name}: #{msg}") if @logger
89
+ end
90
+
81
91
  def add_request_fields(event, env)
82
92
  event.add_field('name', "#{env['REQUEST_METHOD']} #{env['PATH_INFO']}")
83
93
 
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Honeycomb
3
- VERSION="0.2.1"
3
+ VERSION="0.2.2"
4
4
  end
5
5
  end
@@ -36,4 +36,5 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency 'rack-test'
37
37
  spec.add_development_dependency 'sinatra'
38
38
  spec.add_development_dependency 'yard'
39
+ spec.add_development_dependency 'pry-byebug'
39
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-honeycomb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Honeycomb.io Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-24 00:00:00.000000000 Z
11
+ date: 2018-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bump
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry-byebug
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  description: Rack middleware for logging request data to Honeycomb.
140
154
  email: support@honeycomb.io
141
155
  executables: []