faraday-honeycomb 0.0.2 → 0.0.3

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
- SHA1:
3
- metadata.gz: 528655cf7e365e6f896409616b92a37d88dc8dcc
4
- data.tar.gz: 750102a966db633f9318b112f9cddcbf2520824e
2
+ SHA256:
3
+ metadata.gz: a75e1c7076952aa2d4583729d7952714996ca1e78ce2db4744a3ca947d897776
4
+ data.tar.gz: aaa17e9dcd7d330528c9240f876c9f5772073c40a0d7d315e380c82fa05077f0
5
5
  SHA512:
6
- metadata.gz: d483d76fe1fc6087d1acb12f4bd6d51c1e5f75099466633868605f38d42d69cfb2cb67bf203dbfbcfbd831f4a293071b409ea256dfd62036598543676bfbe244
7
- data.tar.gz: d5beb0e6701bbe26ec07e0518849b35174bbf408c3faf6944d520f3cf269859eabe7debe4f284b65147fb262ff97542db47c8c97a3e3d95328f1e90c6f90801b
6
+ metadata.gz: 460b2e4d398de2debd98d4cae9e1c27b56f6fcc8b901270f8dbc58d3b4fc04ea587db44a0b213c933910268b5dd411f8ee11a660895680c42fbb6e0829ce1ceb
7
+ data.tar.gz: d416b7d6d336469ae782190547625bb4c88edc3397508fe4ed16df081670363d5b01a601e84add233e84f3231fa47b600f30bacc8290fa223ff4db57f831bdb6
@@ -10,43 +10,61 @@ module Faraday
10
10
 
11
11
  class Middleware
12
12
  def initialize(app, options = {})
13
- @honeycomb = options[:client] || Libhoney::Client.new(options.merge(user_agent_addition: USER_AGENT_SUFFIX))
13
+ honeycomb = options[:client] || Libhoney::Client.new(options.merge(user_agent_addition: USER_AGENT_SUFFIX))
14
+ @builder = honeycomb.builder.
15
+ add(
16
+ 'type' => 'http_client',
17
+ 'meta.package' => 'faraday',
18
+ 'meta.package_version' => Faraday::VERSION,
19
+ )
14
20
  @app = app
15
21
  end
16
22
 
17
23
  def call(env)
18
- event = @honeycomb.event
24
+ event = @builder.event
19
25
 
20
- event.add_field :url, env.url.to_s
21
-
22
- event.add_field :protocol, env.url.scheme
23
- event.add_field :host, env.url.host
24
- event.add_field :path, env.url.path
26
+ add_request_fields(event, env)
25
27
 
26
28
  start = Time.now
27
29
  response = adding_span_metadata_if_available(event, env) do
28
30
  @app.call(env)
29
31
  end
30
32
 
31
- event.add_field :status, response.status
33
+ add_response_fields(event, response)
32
34
 
33
35
  response
34
36
  rescue Exception => e
35
37
  if event
36
- event.add_field :exception_class, e.class
37
- event.add_field :exception_message, e.message
38
+ event.add_field 'request.error', e.class.name
39
+ event.add_field 'request.error_detail', e.message
38
40
  end
39
41
  raise
40
42
  ensure
41
43
  if start && event
42
44
  finish = Time.now
43
45
  duration = finish - start
44
- event.add_field :durationMs, duration * 1000
46
+ event.add_field 'duration_ms', duration * 1000
45
47
  event.send
46
48
  end
47
49
  end
48
50
 
49
51
  private
52
+ def add_request_fields(event, env)
53
+ loud_method = env.method.upcase.to_s
54
+
55
+ event.add(
56
+ 'name' => "#{loud_method} #{env.url.host}#{env.url.path}",
57
+ 'request.method' => loud_method,
58
+ 'request.protocol' => env.url.scheme,
59
+ 'request.host' => env.url.host,
60
+ 'request.path' => env.url.path,
61
+ )
62
+ end
63
+
64
+ def add_response_fields(event, response)
65
+ event.add_field 'response.status_code', response.status
66
+ end
67
+
50
68
  def adding_span_metadata_if_available(event, env)
51
69
  return yield unless defined?(::Honeycomb.trace_id)
52
70
 
@@ -1,7 +1,7 @@
1
1
  module Faraday
2
2
  module Honeycomb
3
3
  GEM_NAME = 'faraday-honeycomb'
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.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.0.2
4
+ version: 0.0.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-05-07 00:00:00.000000000 Z
11
+ date: 2018-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libhoney
@@ -94,7 +94,8 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: " TO DO *is* a description\n"
97
+ description: |2
98
+ TO DO *is* a description
98
99
  email:
99
100
  - sam@honeycomb.io
100
101
  executables: []
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
127
  version: '0'
127
128
  requirements: []
128
129
  rubyforge_project:
129
- rubygems_version: 2.6.11
130
+ rubygems_version: 2.7.6
130
131
  signing_key:
131
132
  specification_version: 4
132
133
  summary: Instrument your Faraday HTTP requests with Honeycomb