httprb-opentracing 0.3.0 → 0.4.0.pre
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 +4 -4
- data/Gemfile.lock +7 -7
- data/README.md +1 -1
- data/lib/http/tracer.rb +20 -21
- data/lib/http/tracer/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e601dfdf8da237f5fe9141cdc60700ff86fc2171
|
4
|
+
data.tar.gz: 352c715930e748714e3005653c7438f9957d4b0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b15e644bca4cc6ef7ab3c16cd50c22ae56b2019b6d99dcd74f7f80fbcb4c0e11016a0b6baf79404b12ff1874e20d830a46e7bae47e6941e1bbb60d17c4c4fd6
|
7
|
+
data.tar.gz: 364b19b2e0034991269655bcc7f807a27025126bc14c6c01837a1f06c8403ecdbbcad9c2d44cf9f5240c4e9c2ce63a395d419ac4a40757a55c6187397f10beb8
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
httprb-opentracing (0.
|
4
|
+
httprb-opentracing (0.4.0.pre)
|
5
5
|
opentracing (~> 0.5.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
addressable (2.
|
11
|
-
public_suffix (>= 2.0.2, <
|
10
|
+
addressable (2.7.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
12
|
byebug (11.0.1)
|
13
13
|
crack (0.4.3)
|
14
14
|
safe_yaml (~> 1.0.0)
|
@@ -16,19 +16,19 @@ GEM
|
|
16
16
|
domain_name (0.5.20190701)
|
17
17
|
unf (>= 0.0.5, < 1.0.0)
|
18
18
|
hashdiff (1.0.0)
|
19
|
-
http (
|
19
|
+
http (4.1.1)
|
20
20
|
addressable (~> 2.3)
|
21
21
|
http-cookie (~> 1.0)
|
22
|
-
http-form_data (~>
|
22
|
+
http-form_data (~> 2.0)
|
23
23
|
http_parser.rb (~> 0.6.0)
|
24
24
|
http-cookie (1.0.3)
|
25
25
|
domain_name (~> 0.5)
|
26
|
-
http-form_data (1.
|
26
|
+
http-form_data (2.1.1)
|
27
27
|
http_parser.rb (0.6.0)
|
28
28
|
opentracing (0.5.0)
|
29
29
|
opentracing_test_tracer (0.1.1)
|
30
30
|
opentracing
|
31
|
-
public_suffix (
|
31
|
+
public_suffix (4.0.1)
|
32
32
|
rake (10.5.0)
|
33
33
|
rspec (3.8.0)
|
34
34
|
rspec-core (~> 3.8.0)
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ If you need more control over the tracer or which requests get their own span yo
|
|
33
33
|
```
|
34
34
|
HTTP::Tracer.instrument(
|
35
35
|
tracer: tracer,
|
36
|
-
ignore_request: ->(
|
36
|
+
ignore_request: ->(request, opts) { request.uri.host == 'localhost' }
|
37
37
|
)
|
38
38
|
```
|
39
39
|
|
data/lib/http/tracer.rb
CHANGED
@@ -8,7 +8,7 @@ module HTTP
|
|
8
8
|
class << self
|
9
9
|
attr_accessor :ignore_request, :tracer
|
10
10
|
|
11
|
-
IngoreRequest = ->(
|
11
|
+
IngoreRequest = ->(_request, _options) { false }
|
12
12
|
|
13
13
|
def instrument(tracer: OpenTracing.global_tracer, ignore_request: IngoreRequest)
|
14
14
|
begin
|
@@ -20,7 +20,7 @@ module HTTP
|
|
20
20
|
|
21
21
|
@ignore_request = ignore_request
|
22
22
|
@tracer = tracer
|
23
|
-
|
23
|
+
patch_perform
|
24
24
|
end
|
25
25
|
|
26
26
|
def compatible_version?
|
@@ -28,30 +28,26 @@ module HTTP
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def remove
|
31
|
-
return unless ::HTTP::Client.method_defined?(:
|
31
|
+
return unless ::HTTP::Client.method_defined?(:perform_without_tracing)
|
32
32
|
|
33
33
|
::HTTP::Client.class_eval do
|
34
|
-
remove_method :
|
35
|
-
alias_method :
|
36
|
-
remove_method :
|
34
|
+
remove_method :perform
|
35
|
+
alias_method :perform, :perform_without_tracing
|
36
|
+
remove_method :perform_without_tracing
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
40
|
+
def patch_perform
|
41
41
|
::HTTP::Client.class_eval do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
options = HTTP::Options.new.merge(opts)
|
46
|
-
parsed_uri = uri.is_a?(String) ? URI(uri) : uri
|
47
|
-
|
48
|
-
if ::HTTP::Tracer.ignore_request.call(verb, uri, options)
|
49
|
-
res = request_original(verb, uri, options)
|
42
|
+
def perform_with_tracing(request, options)
|
43
|
+
if ::HTTP::Tracer.ignore_request.call(request, options)
|
44
|
+
res = perform_without_tracing(request, options)
|
50
45
|
else
|
51
|
-
path, host, port = nil
|
52
|
-
path =
|
53
|
-
host =
|
54
|
-
port =
|
46
|
+
path, host, port, verb = nil
|
47
|
+
path = request.uri.path if request.uri.respond_to?(:path)
|
48
|
+
host = request.uri.host if request.uri.respond_to?(:host)
|
49
|
+
port = request.uri.port if request.uri.respond_to?(:port)
|
50
|
+
verb = request.verb.to_s.upcase if request.respond_to?(:verb)
|
55
51
|
|
56
52
|
tags = {
|
57
53
|
'component' => 'ruby-httprb',
|
@@ -60,14 +56,14 @@ module HTTP
|
|
60
56
|
'http.url' => path,
|
61
57
|
'peer.host' => host,
|
62
58
|
'peer.port' => port
|
63
|
-
}
|
59
|
+
}.compact
|
64
60
|
|
65
61
|
tracer = ::HTTP::Tracer.tracer
|
66
62
|
|
67
63
|
tracer.start_active_span('http.request', tags: tags) do |scope|
|
68
64
|
OpenTracing.inject(scope.span.context, OpenTracing::FORMAT_RACK, options.headers)
|
69
65
|
|
70
|
-
res =
|
66
|
+
res = perform_without_tracing(request, options)
|
71
67
|
|
72
68
|
scope.span.set_tag('http.status_code', res.status)
|
73
69
|
scope.span.set_tag('error', true) if res.is_a?(StandardError)
|
@@ -76,6 +72,9 @@ module HTTP
|
|
76
72
|
|
77
73
|
res
|
78
74
|
end
|
75
|
+
|
76
|
+
alias perform_without_tracing perform
|
77
|
+
alias perform perform_with_tracing
|
79
78
|
end
|
80
79
|
end
|
81
80
|
end
|
data/lib/http/tracer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httprb-opentracing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Fischer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentracing
|
@@ -164,9 +164,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: '0'
|
165
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
166
|
requirements:
|
167
|
-
- - "
|
167
|
+
- - ">"
|
168
168
|
- !ruby/object:Gem::Version
|
169
|
-
version:
|
169
|
+
version: 1.3.1
|
170
170
|
requirements: []
|
171
171
|
rubyforge_project:
|
172
172
|
rubygems_version: 2.5.2.3
|