signalfx-tracing 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +75 -17
- data/lib/signalfx/tracing/instrumentation/grape.rb +57 -0
- data/lib/signalfx/tracing/instrumentation/rails.rb +14 -7
- data/lib/signalfx/tracing/instrumentation/sequel.rb +28 -0
- data/lib/signalfx/tracing/register.rb +2 -0
- data/lib/signalfx/tracing/version.rb +1 -1
- data/signalfx-tracing.gemspec +3 -1
- metadata +36 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cb7c6cd9186c6b200d8f49f568c408ad95ac990b178b463ee5eda7631d17cd3
|
4
|
+
data.tar.gz: d3356e20ea75c5914fa09a2da0d0f45890bd37be0dc2c2f43ed8bccfdd5673e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9efc8169781a8a48507606d8af68cf04f138863b3ebe26690bcead5dd2b26b4936a83e23890d8c0826f4a63351e52e136163ea9edcb731a9059c858985307d22
|
7
|
+
data.tar.gz: 3028ae140b2ed3e2b0aae422c2385c7f83d3ef7befc25adf497dbe9c9e8521a20cabc17ea1fcd7109cd0bb6aee1fbb3e2762cc70e23c82c06f02acd99c7a003a
|
data/README.md
CHANGED
@@ -90,19 +90,21 @@ When interfacing with these web servers as a Rack application, please configure
|
|
90
90
|
|
91
91
|
### Libraries/Frameworks
|
92
92
|
|
93
|
-
| Library
|
94
|
-
|
|
95
|
-
| ActiveRecord
|
96
|
-
| Elasticsearch
|
97
|
-
| Faraday
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
93
|
+
| Library | Versions Supported |
|
94
|
+
| ----------------------------------- | ------------------ |
|
95
|
+
| [ActiveRecord](#active-record) | > 3.2 |
|
96
|
+
| [Elasticsearch](#elasticsearch) | >= 5.x |
|
97
|
+
| [Faraday](#faraday) | > 0.9.2 |
|
98
|
+
| [Grape](#grape) | > 1.0.0 |
|
99
|
+
| [Mongo](#mongo) | >= 2.1 |
|
100
|
+
| [Mysql2](#mysql2) | >= 0.5.0 |
|
101
|
+
| [Net::HTTP](#nethttp) | Ruby > 2.0 |
|
102
|
+
| [Rack](#rack) | >= 2.0 |
|
103
|
+
| [Rails](#rails) | >= 4.2.0 |
|
104
|
+
| [Redis](#redis) | >= 4.0.1 |
|
105
|
+
| [RestClient](#restclient) | >= 2.0.0 |
|
106
|
+
| [Sequel](#sequel) | >= 3.48.0 |
|
107
|
+
| [Sinatra](#sinatra) | >= 1.1.4 |
|
106
108
|
|
107
109
|
## Active Record
|
108
110
|
|
@@ -177,6 +179,41 @@ end
|
|
177
179
|
|
178
180
|
For more detailed usage, please check the instrumentation's page.
|
179
181
|
|
182
|
+
## Grape
|
183
|
+
|
184
|
+
This instrumentation subscribes to ActiveSupport notifications emitted by the
|
185
|
+
Grape API. It patches `Grape::API` to automatically insert the `Rack::Tracer`
|
186
|
+
middleware and trace requests.
|
187
|
+
|
188
|
+
The source for this instrumentation is located [here](https://github.com/signalfx/ruby-grape-instrumentation)
|
189
|
+
|
190
|
+
### Usage
|
191
|
+
|
192
|
+
```ruby
|
193
|
+
SignalFx::Tracing::Instrumenter.configure do |p|
|
194
|
+
p.instrument(:Grape)
|
195
|
+
end
|
196
|
+
```
|
197
|
+
|
198
|
+
`instrument` takes these optional arguments:
|
199
|
+
- `tracer`: custom tracer to use. Defaults to `OpenTracing.global_tracer`
|
200
|
+
- `parent_span`: parent span to group spans or block that returns a span. Default: `nil`
|
201
|
+
- `disable_patching`: disable patching if managing the middleware stack manually. Default: `false`
|
202
|
+
|
203
|
+
If patching is disabled, but spans nested by request are still desired, then the
|
204
|
+
Rack middleware must be manually added to the API class.
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
require 'rack/tracer'
|
208
|
+
|
209
|
+
class MyAPI << Grape::API
|
210
|
+
insert 0, Rack::Tracer
|
211
|
+
...
|
212
|
+
end
|
213
|
+
```
|
214
|
+
|
215
|
+
Please see the instrumentation's page for more details.
|
216
|
+
|
180
217
|
## Mongo
|
181
218
|
|
182
219
|
Mongo driver instrumentation traces queries performed through the Ruby Mongodb driver.
|
@@ -242,10 +279,9 @@ use Rack::Tracer
|
|
242
279
|
## Rails
|
243
280
|
|
244
281
|
Rails applications can be traced using the notifications provided by ActiveSupport.
|
245
|
-
It
|
246
|
-
request ID.
|
282
|
+
It will use `rack-tracer` to trace by requests.
|
247
283
|
|
248
|
-
The forked source for this instrumentation is located [here](https://github.com/signalfx/ruby-rails-
|
284
|
+
The forked source for this instrumentation is located [here](https://github.com/signalfx/ruby-rails-instrumentation).
|
249
285
|
|
250
286
|
### Usage
|
251
287
|
|
@@ -259,10 +295,14 @@ Optionally, to disable Rack instrumentation, set the `rack_tracer` field to fals
|
|
259
295
|
|
260
296
|
```ruby
|
261
297
|
SignalFx::Tracing::Instrumenter.configure do |p|
|
262
|
-
p.instrument(:Rails, rack_tracer: false)
|
298
|
+
p.instrument(:Rails, rack_tracer: false, exclude_events: [])
|
263
299
|
end
|
264
300
|
```
|
265
301
|
|
302
|
+
By default, all Rails ActiveSupport notifications are traced. However, if this
|
303
|
+
is too noisy, events to ignore can be passed as an array as `exclude_events`.
|
304
|
+
A full list of events can be seen on the instrumentation's Readme.
|
305
|
+
|
266
306
|
Note that if `rack_tracer` is set to `false`, requests propagated to the Rails
|
267
307
|
app will not be extracted. For example, if a traced service makes a request to
|
268
308
|
an endpoint served by the Rails app, it will not be automatically nested.
|
@@ -306,6 +346,24 @@ Arguments:
|
|
306
346
|
- `propagate`: Propagate spans to the request endpoint.
|
307
347
|
- Default: `false`
|
308
348
|
|
349
|
+
## Sequel
|
350
|
+
|
351
|
+
Sequel instrumentation adds extensions to the Database and Dataset to trace queries.
|
352
|
+
|
353
|
+
The source for this instrumentation is located [here](https://github.com/signalfx/ruby-sequel-instrumentation).
|
354
|
+
|
355
|
+
### Usage
|
356
|
+
|
357
|
+
```ruby
|
358
|
+
SignalFx::Tracing::Instrumenter.configure do |p|
|
359
|
+
p.instrument(:Sequel)
|
360
|
+
end
|
361
|
+
```
|
362
|
+
|
363
|
+
Arguments:
|
364
|
+
- `tracer`: Optional custom tracer for this instrumentation
|
365
|
+
- Default: `OpenTracing.global_tracer`
|
366
|
+
|
309
367
|
## Sinatra
|
310
368
|
|
311
369
|
Sinatra instrumentation traces requests and template rendering. The instrumenter
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'opentracing'
|
2
|
+
|
3
|
+
module SignalFx
|
4
|
+
module Tracing
|
5
|
+
module Instrumenter
|
6
|
+
module Grape
|
7
|
+
|
8
|
+
Register.add_lib :Grape, self
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def instrument(opts = {})
|
13
|
+
return if @instrumented
|
14
|
+
|
15
|
+
begin
|
16
|
+
require 'grape'
|
17
|
+
rescue LoadError => error
|
18
|
+
return
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'grape/instrumentation'
|
22
|
+
|
23
|
+
tracer = opts.fetch(:tracer, OpenTracing.global_tracer)
|
24
|
+
parent_span = opts.fetch(:parent_span, nil)
|
25
|
+
|
26
|
+
::Grape::Instrumentation.instrument(tracer: tracer, parent_span: parent_span)
|
27
|
+
patch_middleware if !opts.fetch(:disable_patching, false)
|
28
|
+
|
29
|
+
@instrumented = true
|
30
|
+
end
|
31
|
+
|
32
|
+
def patch_middleware
|
33
|
+
require 'rack/tracer'
|
34
|
+
|
35
|
+
::Grape::API.class_eval do
|
36
|
+
if Gem::Version.new(::Grape::VERSION) >= Gem::Version.new('1.2.0')
|
37
|
+
singleton_class.send(:alias_method, :initial_setup_original, :initial_setup)
|
38
|
+
|
39
|
+
def self.initial_setup(base_instance_parent)
|
40
|
+
initial_setup_original(base_instance_parent)
|
41
|
+
base_instance_parent.insert(0, ::Rack::Tracer) if !base_instance_parent.middleware.any? { |m| m[2].to_s == 'Rack::Tracer'}
|
42
|
+
end
|
43
|
+
else
|
44
|
+
singleton_class.send(:alias_method, :inherited_original, :initial_setup)
|
45
|
+
|
46
|
+
def self.inherited(api)
|
47
|
+
inherited_original(api)
|
48
|
+
api.use(::Rack::Tracer) if !api.middleware.any? { |m| m[1].to_s == 'Rack::Tracer' }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end # class_eval
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -10,19 +10,26 @@ module SignalFx
|
|
10
10
|
def instrument(opts = {})
|
11
11
|
return if @instrumented
|
12
12
|
|
13
|
-
#
|
14
|
-
|
13
|
+
# check for required gems
|
14
|
+
begin
|
15
|
+
require 'active_support'
|
16
|
+
require 'rails'
|
17
|
+
rescue LoadError
|
18
|
+
return
|
19
|
+
end
|
15
20
|
|
16
|
-
require 'rails/
|
21
|
+
require 'rails/instrumentation'
|
17
22
|
require 'rack/tracer'
|
18
23
|
|
19
|
-
if opts.fetch(:rack_tracer,
|
24
|
+
if opts.fetch(:rack_tracer, true)
|
20
25
|
# add rack middlewares
|
21
|
-
::Rails.configuration.middleware.
|
22
|
-
::Rails.configuration.middleware.insert_after(::Rack::Tracer, ::Rails::Rack::Tracer)
|
26
|
+
::Rails.configuration.middleware.insert(0, ::Rack::Tracer)
|
23
27
|
end
|
24
28
|
|
25
|
-
|
29
|
+
exclude_events = opts.fetch(:exclude_events, [])
|
30
|
+
tracer = opts.fetch(:tracer, OpenTracing.global_tracer)
|
31
|
+
|
32
|
+
::Rails::Instrumentation.instrument(tracer: tracer, exclude_events: exclude_events)
|
26
33
|
|
27
34
|
@instrumented = true
|
28
35
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module SignalFx
|
2
|
+
module Tracing
|
3
|
+
module Instrumenter
|
4
|
+
module Sequel
|
5
|
+
|
6
|
+
Register.add_lib :Sequel, self
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
def instrument(opts = {})
|
11
|
+
begin
|
12
|
+
require 'sequel'
|
13
|
+
rescue LoadError
|
14
|
+
return
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'sequel/instrumentation'
|
18
|
+
|
19
|
+
tracer = opts.fetch(:tracer, OpenTracing.global_tracer)
|
20
|
+
|
21
|
+
::Sequel::Instrumentation.instrument(tracer: tracer) if !@instrumented
|
22
|
+
@instrumented = true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -40,3 +40,5 @@ require 'signalfx/tracing/instrumentation/mongodb'
|
|
40
40
|
require 'signalfx/tracing/instrumentation/elasticsearch'
|
41
41
|
require 'signalfx/tracing/instrumentation/mysql2'
|
42
42
|
require 'signalfx/tracing/instrumentation/redis'
|
43
|
+
require 'signalfx/tracing/instrumentation/sequel'
|
44
|
+
require 'signalfx/tracing/instrumentation/grape'
|
data/signalfx-tracing.gemspec
CHANGED
@@ -44,9 +44,11 @@ Gem::Specification.new do |spec|
|
|
44
44
|
spec.add_dependency "mongodb-instrumentation", "~> 0.1.1"
|
45
45
|
spec.add_dependency "mysql2-instrumentation", "~> 0.1.0"
|
46
46
|
spec.add_dependency "redis-instrumentation", "~> 0.1.0"
|
47
|
+
spec.add_dependency "sequel-instrumentation", "~> 0.1.0"
|
48
|
+
spec.add_dependency "grape-instrumentation", "~> 0.1.0"
|
49
|
+
spec.add_dependency "rails-instrumentation", "~> 0.1.0"
|
47
50
|
|
48
51
|
# forks
|
49
|
-
spec.add_dependency "signalfx-rails-instrumentation", "~> 0.1.4"
|
50
52
|
spec.add_dependency "signalfx-elasticsearch-instrumentation", "~> 0.1.0"
|
51
53
|
spec.add_dependency "signalfx-faraday-instrumentation", "~> 0.1.1"
|
52
54
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: signalfx-tracing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashwin Chandrasekar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -151,19 +151,47 @@ dependencies:
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.1.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: sequel-instrumentation
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.1.
|
159
|
+
version: 0.1.0
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.1.0
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: grape-instrumentation
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.1.0
|
160
174
|
type: :runtime
|
161
175
|
prerelease: false
|
162
176
|
version_requirements: !ruby/object:Gem::Requirement
|
163
177
|
requirements:
|
164
178
|
- - "~>"
|
165
179
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.1.
|
180
|
+
version: 0.1.0
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rails-instrumentation
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 0.1.0
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 0.1.0
|
167
195
|
- !ruby/object:Gem::Dependency
|
168
196
|
name: signalfx-elasticsearch-instrumentation
|
169
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -240,6 +268,7 @@ files:
|
|
240
268
|
- lib/signalfx/tracing/instrumentation/active_record.rb
|
241
269
|
- lib/signalfx/tracing/instrumentation/elasticsearch.rb
|
242
270
|
- lib/signalfx/tracing/instrumentation/faraday.rb
|
271
|
+
- lib/signalfx/tracing/instrumentation/grape.rb
|
243
272
|
- lib/signalfx/tracing/instrumentation/mongodb.rb
|
244
273
|
- lib/signalfx/tracing/instrumentation/mysql2.rb
|
245
274
|
- lib/signalfx/tracing/instrumentation/net_http.rb
|
@@ -248,6 +277,7 @@ files:
|
|
248
277
|
- lib/signalfx/tracing/instrumentation/rails.rb
|
249
278
|
- lib/signalfx/tracing/instrumentation/redis.rb
|
250
279
|
- lib/signalfx/tracing/instrumentation/restclient.rb
|
280
|
+
- lib/signalfx/tracing/instrumentation/sequel.rb
|
251
281
|
- lib/signalfx/tracing/instrumentation/sinatra.rb
|
252
282
|
- lib/signalfx/tracing/register.rb
|
253
283
|
- lib/signalfx/tracing/reporter/auto_reviving_async_reporter.rb
|
@@ -273,8 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
303
|
- !ruby/object:Gem::Version
|
274
304
|
version: '0'
|
275
305
|
requirements: []
|
276
|
-
|
277
|
-
rubygems_version: 2.7.3
|
306
|
+
rubygems_version: 3.0.2
|
278
307
|
signing_key:
|
279
308
|
specification_version: 4
|
280
309
|
summary: Auto-instrumentation framework for Ruby
|