rack-tracer 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +22 -0
- data/Rakefile +6 -3
- data/bin/console +3 -3
- data/lib/rack/tracer.rb +19 -9
- data/rack-tracer.gemspec +10 -7
- metadata +51 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a5669fdb260f9f92c7d6b807bd55bd4ac3a1560
|
4
|
+
data.tar.gz: 8682a3f0904f69efd5f3f3a6af4af9f170dd9150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4db8628c41fb256fa56d2a949abdc2e499c183f2a73d56ee1aff640e9308ee703272bcdaed058917b0cb07df83297f31c22daaa93ef18b7404bdf08a3df540df
|
7
|
+
data.tar.gz: '0900be47a4c70cad280587b92387ae5b46e220805d0d656edce7e7ff37f57599ca9f657466a7d3fdcf819aa11b2885b046a140823ad37ca1c8c4415b6dd25082'
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
Metrics/AbcSize:
|
4
|
+
Enabled: no
|
5
|
+
|
6
|
+
Metrics/BlockLength:
|
7
|
+
Enabled: no
|
8
|
+
|
9
|
+
Metrics/LineLength:
|
10
|
+
Max: 120
|
11
|
+
|
12
|
+
Metrics/MethodLength:
|
13
|
+
Enabled: no
|
14
|
+
|
15
|
+
Style/Documentation:
|
16
|
+
Enabled: no
|
17
|
+
|
18
|
+
RSpec/ExampleLength:
|
19
|
+
Enabled: no
|
20
|
+
|
21
|
+
RSpec/MultipleExpectations:
|
22
|
+
Enabled: no
|
data/Rakefile
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
6
|
-
|
7
|
+
RuboCop::RakeTask.new(:rubocop)
|
8
|
+
|
9
|
+
task default: %i[rubocop spec]
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'rack/tracer'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "rack/tracer"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/lib/rack/tracer.rb
CHANGED
@@ -14,7 +14,12 @@ module Rack
|
|
14
14
|
# @param on_finish_span [Proc, nil] A callback evaluated after a span is finished.
|
15
15
|
# @param errors [Array<Class>] An array of error classes to be captured by the tracer
|
16
16
|
# as errors. Errors are **not** muted by the middleware, they're re-raised afterwards.
|
17
|
-
def initialize(app,
|
17
|
+
def initialize(app, # rubocop:disable Metrics/ParameterLists
|
18
|
+
tracer: OpenTracing.global_tracer,
|
19
|
+
on_start_span: nil,
|
20
|
+
on_finish_span: nil,
|
21
|
+
trust_incoming_span: true,
|
22
|
+
errors: [StandardError])
|
18
23
|
@app = app
|
19
24
|
@tracer = tracer
|
20
25
|
@on_start_span = on_start_span
|
@@ -27,7 +32,8 @@ module Rack
|
|
27
32
|
method = env[REQUEST_METHOD]
|
28
33
|
|
29
34
|
context = @tracer.extract(OpenTracing::FORMAT_RACK, env) if @trust_incoming_span
|
30
|
-
span = @tracer.start_span(
|
35
|
+
span = @tracer.start_span(
|
36
|
+
method,
|
31
37
|
child_of: context,
|
32
38
|
tags: {
|
33
39
|
'component' => 'rack',
|
@@ -45,13 +51,18 @@ module Rack
|
|
45
51
|
@app.call(env).tap do |status_code, _headers, _body|
|
46
52
|
span.set_tag('http.status_code', status_code)
|
47
53
|
|
48
|
-
|
49
|
-
|
50
|
-
end
|
54
|
+
route = route_from_env(env)
|
55
|
+
span.set_tag('route', route) if route
|
51
56
|
end
|
52
57
|
rescue *@errors => e
|
53
58
|
span.set_tag('error', true)
|
54
|
-
span.
|
59
|
+
span.log_kv(
|
60
|
+
event: 'error',
|
61
|
+
:'error.kind' => e.class.to_s,
|
62
|
+
:'error.object' => e,
|
63
|
+
message: e.message,
|
64
|
+
stack: e.backtrace.join("\n")
|
65
|
+
)
|
55
66
|
raise
|
56
67
|
ensure
|
57
68
|
begin
|
@@ -64,9 +75,8 @@ module Rack
|
|
64
75
|
private
|
65
76
|
|
66
77
|
def route_from_env(env)
|
67
|
-
|
68
|
-
|
69
|
-
end
|
78
|
+
route = env['sinatra.route']
|
79
|
+
route.split(' ').last if route
|
70
80
|
end
|
71
81
|
end
|
72
82
|
end
|
data/rack-tracer.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('
|
1
|
+
|
2
|
+
lib = File.expand_path('lib', __dir__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'rack-tracer'
|
7
|
-
spec.version = '0.
|
7
|
+
spec.version = '0.6.0'
|
8
8
|
spec.authors = ['SaleMove TechMovers']
|
9
9
|
spec.email = ['techmovers@salemove.com']
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
11
|
+
spec.summary = 'Rack OpenTracing middleware'
|
12
|
+
spec.description = ''
|
13
13
|
spec.homepage = 'https://github.com/opentracing-contrib/ruby-rack-tracer'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
@@ -21,8 +21,11 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'opentracing'
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
24
|
+
spec.add_development_dependency 'rack', '~> 2.0'
|
24
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
25
26
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
-
spec.add_development_dependency '
|
27
|
-
spec.add_development_dependency '
|
27
|
+
spec.add_development_dependency 'rubocop', '~> 0.54.0'
|
28
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.24.0'
|
29
|
+
spec.add_development_dependency 'test-tracer', '~> 1.0'
|
30
|
+
spec.add_development_dependency 'tracing-matchers', '~> 1.0'
|
28
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-tracer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SaleMove TechMovers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentracing
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.14'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rack
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,33 +81,61 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '3.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: rubocop
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
89
|
+
version: 0.54.0
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
96
|
+
version: 0.54.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: rubocop-rspec
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: 1.24.0
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: 1.24.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: test-tracer
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: tracing-matchers
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.0'
|
97
139
|
description: ''
|
98
140
|
email:
|
99
141
|
- techmovers@salemove.com
|
@@ -103,6 +145,7 @@ extra_rdoc_files: []
|
|
103
145
|
files:
|
104
146
|
- ".gitignore"
|
105
147
|
- ".rspec"
|
148
|
+
- ".rubocop.yml"
|
106
149
|
- ".travis.yml"
|
107
150
|
- Gemfile
|
108
151
|
- LICENSE.txt
|