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 +5 -5
- data/lib/faraday/honeycomb/middleware.rb +29 -11
- data/lib/faraday/honeycomb/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a75e1c7076952aa2d4583729d7952714996ca1e78ce2db4744a3ca947d897776
|
4
|
+
data.tar.gz: aaa17e9dcd7d330528c9240f876c9f5772073c40a0d7d315e380c82fa05077f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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 = @
|
24
|
+
event = @builder.event
|
19
25
|
|
20
|
-
event
|
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
|
33
|
+
add_response_fields(event, response)
|
32
34
|
|
33
35
|
response
|
34
36
|
rescue Exception => e
|
35
37
|
if event
|
36
|
-
event.add_field
|
37
|
-
event.add_field
|
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
|
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
|
|
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.
|
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-
|
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:
|
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
|
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
|