faraday-honeycomb 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 540f228bab59da3cb1fd0fe6f9d78742f8de6201c327637aff03ef38bfeddab8
4
- data.tar.gz: 7e973e706ef49733be242f4437f03c31203337ae66e2b96bba760f0a5d28c5bb
3
+ metadata.gz: d9c9cf8d005f26ecd2f3e391a7695211718480900810d57c1c1656cc1ed5f240
4
+ data.tar.gz: a645970ff844448583057f69f41e758e7643ef3125895bf2936e5d8fa7837522
5
5
  SHA512:
6
- metadata.gz: 692dc42dca8604f1e9a8d92f8296682248890f3225245e3d053625c9b3ea5a5a31c7beee58217ca448d0b87d9b18e391066cf270a58726dd6e5aaf4402d71d68
7
- data.tar.gz: d91e396292fc619b9025bbac3b7cdb387767d80b5b7725c3f963949188e2ad8e8640b9a23c9af5b60a6ea20a764a31eff896d22a03a6d423ee90a3530109956e
6
+ metadata.gz: 283d54bd078a653f7e6b309099f9d3597815eef830bf0a1fc92a423fd3e3a9ca7bca44aa49d9fd5f65797ffdfb324cca4ef88f37f645f4b09b30dd7cdc9152d9
7
+ data.tar.gz: 2acf6c044ba3c1296ecda0562175453edeaee51ed5aa1ce679296d6335e69ddcc33f617b1636e077d6c62dea3958f4742f148efcf60a46c2fa064967e1053281
@@ -23,13 +23,13 @@ module Faraday
23
23
  block = if orig_block
24
24
  proc do |b|
25
25
  logger.debug "Adding Faraday::Honeycomb::Middleware in #{self}.new{}" if logger
26
- b.use :honeycomb, client: honeycomb_client
26
+ b.use :honeycomb, client: honeycomb_client, logger: logger
27
27
  orig_block.call(b)
28
28
  end
29
29
  else
30
30
  proc do |b|
31
31
  logger.debug "Adding Faraday::Honeycomb::Middleware in #{self}.new" if logger
32
- b.use :honeycomb, client: honeycomb_client
32
+ b.use :honeycomb, client: honeycomb_client, logger: logger
33
33
  b.adapter Faraday.default_adapter
34
34
  end
35
35
  end
@@ -9,8 +9,20 @@ module Faraday
9
9
  USER_AGENT_SUFFIX = "#{GEM_NAME}/#{VERSION}"
10
10
 
11
11
  class Middleware
12
- def initialize(app, options = {})
13
- honeycomb = options[:client] || Libhoney::Client.new(options.merge(user_agent_addition: USER_AGENT_SUFFIX))
12
+ def initialize(app, client: nil, logger: nil)
13
+ @logger = logger
14
+ @logger ||= ::Honeycomb.logger if defined?(::Honeycomb.logger)
15
+
16
+ honeycomb = if client
17
+ debug "initialized with #{client.class.name} via :client option"
18
+ client
19
+ elsif defined?(::Honeycomb.client)
20
+ debug "initialized with #{::Honeycomb.client.class.name} from honeycomb-beeline"
21
+ ::Honeycomb.client
22
+ else
23
+ debug "initializing new Libhoney::Client"
24
+ Libhoney::Client.new(options.merge(user_agent_addition: USER_AGENT_SUFFIX))
25
+ end
14
26
  @builder = honeycomb.builder.
15
27
  add(
16
28
  'type' => 'http_client',
@@ -49,6 +61,10 @@ module Faraday
49
61
  end
50
62
 
51
63
  private
64
+ def debug(msg)
65
+ @logger.debug("#{self.class.name}: #{msg}") if @logger
66
+ end
67
+
52
68
  def add_request_fields(event, env)
53
69
  loud_method = env.method.upcase.to_s
54
70
 
@@ -1,7 +1,7 @@
1
1
  module Faraday
2
2
  module Honeycomb
3
3
  GEM_NAME = 'faraday-honeycomb'
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.3'
5
5
 
6
6
  MIN_FARADAY_VERSION = '0.8'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-honeycomb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stokes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-07 00:00:00.000000000 Z
11
+ date: 2018-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libhoney
@@ -97,7 +97,7 @@ dependencies:
97
97
  description: |2
98
98
  TO DO *is* a description
99
99
  email:
100
- - sam@honeycomb.io
100
+ - support@honeycomb.io
101
101
  executables: []
102
102
  extensions: []
103
103
  extra_rdoc_files: []