signalfx-rails-instrumentation 0.1.1 → 0.2.1
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 +5 -5
- data/.gitignore +3 -7
- data/.rubocop.yml +42 -0
- data/Appraisals +16 -13
- data/Gemfile +3 -7
- data/Gemfile.lock +173 -0
- data/LICENSE +2 -2
- data/README.md +116 -162
- data/Rakefile +6 -6
- data/bin/console +1 -1
- data/lib/rails/instrumentation.rb +60 -0
- data/lib/rails/instrumentation/patch.rb +38 -0
- data/lib/rails/instrumentation/subscriber.rb +45 -0
- data/lib/rails/instrumentation/subscribers/action_cable_subscriber.rb +69 -0
- data/lib/rails/instrumentation/subscribers/action_controller_subscriber.rb +172 -0
- data/lib/rails/instrumentation/subscribers/action_mailer_subscriber.rb +63 -0
- data/lib/rails/instrumentation/subscribers/action_view_subscriber.rb +48 -0
- data/lib/rails/instrumentation/subscribers/active_job_subscriber.rb +58 -0
- data/lib/rails/instrumentation/subscribers/active_record_subscriber.rb +45 -0
- data/lib/rails/instrumentation/subscribers/active_storage_subscriber.rb +91 -0
- data/lib/rails/instrumentation/subscribers/active_support_subscriber.rb +74 -0
- data/lib/rails/instrumentation/utils.rb +51 -0
- data/lib/rails/instrumentation/version.rb +5 -0
- data/rails-instrumentation.gemspec +32 -0
- metadata +54 -192
- data/.rspec +0 -2
- data/.ruby-version +0 -1
- data/.travis.yml +0 -25
- data/CHANGELOG.md +0 -47
- data/docker-compose.yml +0 -4
- data/gemfiles/.bundle/config +0 -2
- data/gemfiles/rails_32.gemfile +0 -11
- data/gemfiles/rails_4.gemfile +0 -10
- data/gemfiles/rails_40.gemfile +0 -10
- data/gemfiles/rails_41.gemfile +0 -10
- data/gemfiles/rails_42.gemfile +0 -10
- data/gemfiles/rails_5.gemfile +0 -10
- data/gemfiles/rails_50.gemfile +0 -10
- data/gemfiles/rails_51.gemfile +0 -10
- data/lib/rails-tracer.rb +0 -1
- data/lib/rails/action_controller/tracer.rb +0 -100
- data/lib/rails/action_view/tracer.rb +0 -105
- data/lib/rails/active_record/tracer.rb +0 -89
- data/lib/rails/active_support/cache/core_ext.rb +0 -11
- data/lib/rails/active_support/cache/dalli_tracer.rb +0 -106
- data/lib/rails/active_support/cache/manual_tracer.rb +0 -24
- data/lib/rails/active_support/cache/subscriber.rb +0 -62
- data/lib/rails/active_support/cache/tracer.rb +0 -55
- data/lib/rails/defer_notifications.rb +0 -78
- data/lib/rails/rack/tracer.rb +0 -61
- data/lib/rails/span_helpers.rb +0 -24
- data/lib/rails/tracer.rb +0 -38
- data/rails-tracer.gemspec +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: df7cf875738579d6b01612b1974b3143b18800e644b0cc9c19d29c8d84561b19
|
4
|
+
data.tar.gz: 3f51dc73cc822fc5861292c9081fe1cbd4af0617e7ace79d2fa2ff10ee4caac3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2126136ff16f9144b5e7de4a37694723da323a91b0e72f5e250d2a824706a543d464956ee74e8fad28b25f1be090109fc5098d83ba6e6dbc67e82c0cbfa7a57
|
7
|
+
data.tar.gz: a2729daf28ea2b98e96e04008b8132687703dbb33a3250fe9c9cf86b30112c4c3330173a9eeac8a45edda1fcb38969cd419a7b97579a1d275826c93124403da0
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
AllCops:
|
3
|
+
Exclude:
|
4
|
+
- 'test/**/*'
|
5
|
+
- 'gemfiles/**/*'
|
6
|
+
- 'bin/**/*'
|
7
|
+
|
8
|
+
Style/Documentation:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Style/TrailingCommaInHashLiteral:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Metrics/MethodLength:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Metrics/BlockLength:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Metrics/AbcSize:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
RSpec/MultipleExpectations:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
RSpec/ExampleLength:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
RSpec/FilePath:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
RSpec/VerifiedDoubles:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Metrics/ModuleLength:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
Metrics/LineLength:
|
39
|
+
Max: 100
|
40
|
+
Exclude:
|
41
|
+
- 'spec/**/*'
|
42
|
+
|
data/Appraisals
CHANGED
@@ -1,24 +1,27 @@
|
|
1
|
-
appraise
|
2
|
-
gem
|
3
|
-
gem 'test-unit', '~> 3.0'
|
1
|
+
appraise 'rails-latest' do
|
2
|
+
gem 'rails'
|
4
3
|
end
|
5
4
|
|
6
|
-
appraise
|
7
|
-
gem
|
5
|
+
appraise 'rails-5.2' do
|
6
|
+
gem 'rails', '~> 5.2.0'
|
8
7
|
end
|
9
8
|
|
10
|
-
appraise
|
11
|
-
gem
|
9
|
+
appraise 'rails-5.1' do
|
10
|
+
gem 'rails', '~> 5.1.0'
|
12
11
|
end
|
13
12
|
|
14
|
-
appraise
|
15
|
-
gem
|
13
|
+
appraise 'rails-5.0' do
|
14
|
+
gem 'rails', '~> 5.0.0'
|
16
15
|
end
|
17
16
|
|
18
|
-
appraise
|
19
|
-
gem
|
17
|
+
appraise 'rails-4.2' do
|
18
|
+
gem 'rails', '~> 4.2.0'
|
20
19
|
end
|
21
20
|
|
22
|
-
appraise
|
23
|
-
gem
|
21
|
+
appraise 'rails-4.1' do
|
22
|
+
gem 'rails', '~> 4.1.0'
|
23
|
+
end
|
24
|
+
|
25
|
+
appraise 'rails-3.2' do
|
26
|
+
gem 'rails', '~> 3.2.0'
|
24
27
|
end
|
data/Gemfile
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
3
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
4
|
|
5
|
-
# Specify your gem's dependencies in rails-
|
5
|
+
# Specify your gem's dependencies in rails-instrumentation.gemspec
|
6
6
|
gemspec
|
7
|
-
|
8
|
-
gem 'pry'
|
9
|
-
gem 'pry-stack_explorer'
|
10
|
-
gem 'pry-byebug'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
signalfx-rails-instrumentation (0.2.1)
|
5
|
+
opentracing (~> 0.3)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actioncable (5.2.4.4)
|
11
|
+
actionpack (= 5.2.4.4)
|
12
|
+
nio4r (~> 2.0)
|
13
|
+
websocket-driver (>= 0.6.1)
|
14
|
+
actionmailer (5.2.4.4)
|
15
|
+
actionpack (= 5.2.4.4)
|
16
|
+
actionview (= 5.2.4.4)
|
17
|
+
activejob (= 5.2.4.4)
|
18
|
+
mail (~> 2.5, >= 2.5.4)
|
19
|
+
rails-dom-testing (~> 2.0)
|
20
|
+
actionpack (5.2.4.4)
|
21
|
+
actionview (= 5.2.4.4)
|
22
|
+
activesupport (= 5.2.4.4)
|
23
|
+
rack (~> 2.0, >= 2.0.8)
|
24
|
+
rack-test (>= 0.6.3)
|
25
|
+
rails-dom-testing (~> 2.0)
|
26
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
27
|
+
actionview (5.2.4.4)
|
28
|
+
activesupport (= 5.2.4.4)
|
29
|
+
builder (~> 3.1)
|
30
|
+
erubi (~> 1.4)
|
31
|
+
rails-dom-testing (~> 2.0)
|
32
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
33
|
+
activejob (5.2.4.4)
|
34
|
+
activesupport (= 5.2.4.4)
|
35
|
+
globalid (>= 0.3.6)
|
36
|
+
activemodel (5.2.4.4)
|
37
|
+
activesupport (= 5.2.4.4)
|
38
|
+
activerecord (5.2.4.4)
|
39
|
+
activemodel (= 5.2.4.4)
|
40
|
+
activesupport (= 5.2.4.4)
|
41
|
+
arel (>= 9.0)
|
42
|
+
activestorage (5.2.4.4)
|
43
|
+
actionpack (= 5.2.4.4)
|
44
|
+
activerecord (= 5.2.4.4)
|
45
|
+
marcel (~> 0.3.1)
|
46
|
+
activesupport (5.2.4.4)
|
47
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
48
|
+
i18n (>= 0.7, < 2)
|
49
|
+
minitest (~> 5.1)
|
50
|
+
tzinfo (~> 1.1)
|
51
|
+
appraisal (2.3.0)
|
52
|
+
bundler
|
53
|
+
rake
|
54
|
+
thor (>= 0.14.0)
|
55
|
+
arel (9.0.0)
|
56
|
+
ast (2.4.1)
|
57
|
+
builder (3.2.4)
|
58
|
+
concurrent-ruby (1.1.7)
|
59
|
+
crass (1.0.6)
|
60
|
+
diff-lcs (1.4.4)
|
61
|
+
erubi (1.10.0)
|
62
|
+
globalid (0.4.2)
|
63
|
+
activesupport (>= 4.2.0)
|
64
|
+
i18n (1.8.5)
|
65
|
+
concurrent-ruby (~> 1.0)
|
66
|
+
jaro_winkler (1.5.4)
|
67
|
+
loofah (2.8.0)
|
68
|
+
crass (~> 1.0.2)
|
69
|
+
nokogiri (>= 1.5.9)
|
70
|
+
mail (2.7.1)
|
71
|
+
mini_mime (>= 0.1.1)
|
72
|
+
marcel (0.3.3)
|
73
|
+
mimemagic (~> 0.3.2)
|
74
|
+
method_source (1.0.0)
|
75
|
+
mimemagic (0.3.5)
|
76
|
+
mini_mime (1.0.2)
|
77
|
+
mini_portile2 (2.4.0)
|
78
|
+
minitest (5.14.2)
|
79
|
+
nio4r (2.5.4)
|
80
|
+
nokogiri (1.10.10)
|
81
|
+
mini_portile2 (~> 2.4.0)
|
82
|
+
opentracing (0.5.0)
|
83
|
+
parallel (1.20.1)
|
84
|
+
parser (2.7.2.0)
|
85
|
+
ast (~> 2.4.1)
|
86
|
+
powerpack (0.1.3)
|
87
|
+
rack (2.2.3)
|
88
|
+
rack-test (1.1.0)
|
89
|
+
rack (>= 1.0, < 3)
|
90
|
+
rails (5.2.4.4)
|
91
|
+
actioncable (= 5.2.4.4)
|
92
|
+
actionmailer (= 5.2.4.4)
|
93
|
+
actionpack (= 5.2.4.4)
|
94
|
+
actionview (= 5.2.4.4)
|
95
|
+
activejob (= 5.2.4.4)
|
96
|
+
activemodel (= 5.2.4.4)
|
97
|
+
activerecord (= 5.2.4.4)
|
98
|
+
activestorage (= 5.2.4.4)
|
99
|
+
activesupport (= 5.2.4.4)
|
100
|
+
bundler (>= 1.3.0)
|
101
|
+
railties (= 5.2.4.4)
|
102
|
+
sprockets-rails (>= 2.0.0)
|
103
|
+
rails-dom-testing (2.0.3)
|
104
|
+
activesupport (>= 4.2.0)
|
105
|
+
nokogiri (>= 1.6)
|
106
|
+
rails-html-sanitizer (1.3.0)
|
107
|
+
loofah (~> 2.3)
|
108
|
+
railties (5.2.4.4)
|
109
|
+
actionpack (= 5.2.4.4)
|
110
|
+
activesupport (= 5.2.4.4)
|
111
|
+
method_source
|
112
|
+
rake (>= 0.8.7)
|
113
|
+
thor (>= 0.19.0, < 2.0)
|
114
|
+
rainbow (3.0.0)
|
115
|
+
rake (10.5.0)
|
116
|
+
rspec (3.10.0)
|
117
|
+
rspec-core (~> 3.10.0)
|
118
|
+
rspec-expectations (~> 3.10.0)
|
119
|
+
rspec-mocks (~> 3.10.0)
|
120
|
+
rspec-core (3.10.0)
|
121
|
+
rspec-support (~> 3.10.0)
|
122
|
+
rspec-expectations (3.10.0)
|
123
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
124
|
+
rspec-support (~> 3.10.0)
|
125
|
+
rspec-mocks (3.10.0)
|
126
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
127
|
+
rspec-support (~> 3.10.0)
|
128
|
+
rspec-support (3.10.0)
|
129
|
+
rubocop (0.63.1)
|
130
|
+
jaro_winkler (~> 1.5.1)
|
131
|
+
parallel (~> 1.10)
|
132
|
+
parser (>= 2.5, != 2.5.1.1)
|
133
|
+
powerpack (~> 0.1)
|
134
|
+
rainbow (>= 2.2.2, < 4.0)
|
135
|
+
ruby-progressbar (~> 1.7)
|
136
|
+
unicode-display_width (~> 1.4.0)
|
137
|
+
rubocop-rspec (1.35.0)
|
138
|
+
rubocop (>= 0.60.0)
|
139
|
+
ruby-progressbar (1.10.1)
|
140
|
+
signalfx_test_tracer (0.1.4)
|
141
|
+
opentracing
|
142
|
+
sprockets (4.0.2)
|
143
|
+
concurrent-ruby (~> 1.0)
|
144
|
+
rack (> 1, < 3)
|
145
|
+
sprockets-rails (3.2.2)
|
146
|
+
actionpack (>= 4.0)
|
147
|
+
activesupport (>= 4.0)
|
148
|
+
sprockets (>= 3.0.0)
|
149
|
+
thor (1.0.1)
|
150
|
+
thread_safe (0.3.6)
|
151
|
+
tzinfo (1.2.8)
|
152
|
+
thread_safe (~> 0.1)
|
153
|
+
unicode-display_width (1.4.1)
|
154
|
+
websocket-driver (0.7.3)
|
155
|
+
websocket-extensions (>= 0.1.0)
|
156
|
+
websocket-extensions (0.1.5)
|
157
|
+
|
158
|
+
PLATFORMS
|
159
|
+
x86_64-darwin-19
|
160
|
+
|
161
|
+
DEPENDENCIES
|
162
|
+
appraisal (~> 2.2)
|
163
|
+
bundler (>= 1.17)
|
164
|
+
rails (~> 5.2.2)
|
165
|
+
rake (~> 10.0)
|
166
|
+
rspec (~> 3.0)
|
167
|
+
rubocop (~> 0.63.0)
|
168
|
+
rubocop-rspec (~> 1.31)
|
169
|
+
signalfx-rails-instrumentation!
|
170
|
+
signalfx_test_tracer (>= 0.1.2)
|
171
|
+
|
172
|
+
BUNDLED WITH
|
173
|
+
2.2.5
|
data/LICENSE
CHANGED
@@ -178,7 +178,7 @@
|
|
178
178
|
APPENDIX: How to apply the Apache License to your work.
|
179
179
|
|
180
180
|
To apply the Apache License to your work, attach the following
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
182
|
replaced with your own identifying information. (Don't include
|
183
183
|
the brackets!) The text should be enclosed in the appropriate
|
184
184
|
comment syntax for the file format. We also recommend that a
|
@@ -186,7 +186,7 @@
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
187
187
|
identification within third-party archives.
|
188
188
|
|
189
|
-
Copyright
|
189
|
+
Copyright 2019 SignalFx
|
190
190
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
192
192
|
you may not use this file except in compliance with the License.
|
data/README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# Rails::Instrumentation
|
2
2
|
|
3
|
-
|
3
|
+
OpenTracing instrumentation for Rails using ActiveSupport notifications. All events
|
4
|
+
currently instrumented by ActiveSupport are available to trace.
|
4
5
|
|
5
|
-
|
6
|
+
## Supported versions
|
6
7
|
|
7
|
-
|
8
|
-
* ActiveRecord - The library hooks up into Rails, and instruments all ActiveRecord query.
|
9
|
-
* ActionSupport::Cache - The library hooks up into Rails, and instruments cache events.
|
8
|
+
- Rails 5.2.x, 5.1.x, 5.0.x, 4.2.x
|
10
9
|
|
11
10
|
## Installation
|
12
11
|
|
@@ -24,175 +23,130 @@ Or install it yourself as:
|
|
24
23
|
|
25
24
|
$ gem install signalfx-rails-instrumentation
|
26
25
|
|
27
|
-
##
|
28
|
-
|
29
|
-
The library hooks up into Rails using `ActiveSupport::Notifications`, and instruments all previously mentioned modules.
|
30
|
-
To enable instrumentation, you can either use sub-tracers directly (see sections below) or global `Rails::Tracer` which
|
31
|
-
will enabled all of them (except for Rack/ActionDispatch instrumentation).
|
32
|
-
|
33
|
-
### Configuration Options
|
34
|
-
|
35
|
-
* `tracer: OpenTracing::Tracer` an OT compatible tracer. Default `OpenTracing.global_tracer`
|
36
|
-
* `active_span: boolean` an active span provider. Default: `nil`.
|
37
|
-
* `active_record: boolean` whether to enable `ActiveRecord` instrumentation. Default: `true`.
|
38
|
-
* `active_support_cache: boolean` whether to enable `ActionDispatch::Cache` instrumentation. Default: `true`.
|
39
|
-
* `dalli: boolean` if set to `true` you will hook up into `Dalli` low-level details. Default: `false`.
|
40
|
-
* `rack: boolean` whether to enable extended `Rack` instrumentation. Default: `false`.
|
41
|
-
* `middlewares: ActionDispatch::MiddlewareStack` a middlewares stack. Default: `Rails.configuration.middleware`.
|
42
|
-
* `action_controller: boolean` whether to enable `ActionController` instrumentation. Default: `true`.
|
43
|
-
* `full_trace: boolean` whether to gather all traces for a request and attempt to build a parent span for the current request. Default: `false`.
|
44
|
-
|
45
|
-
### Usage
|
46
|
-
|
47
|
-
```ruby
|
48
|
-
require 'rails/tracer'
|
49
|
-
|
50
|
-
Rails::Tracer.instrument
|
51
|
-
```
|
52
|
-
|
53
|
-
## ActionDispatch
|
54
|
-
|
55
|
-
When you use `rack-tracer`, the generated operation name corresponds to the request's http method e.g. GET, POST etc.
|
56
|
-
It's not perfect. You need to dig into the trace to understand with what url it's related.
|
57
|
-
|
58
|
-
The `rails-tracer` introduces another rack middleware, which is intended to be used together with `rack-tracer`, to generate more informative operation names in the form `ControllerName#action`.
|
59
|
-
|
60
|
-
### Usage
|
61
|
-
|
62
|
-
```ruby
|
63
|
-
require 'rack/tracer'
|
64
|
-
require 'rails/tracer'
|
65
|
-
|
66
|
-
Rails.configuration.middleware.use(Rack::Tracer)
|
67
|
-
Rails.configuration.middleware.insert_after(Rack::Tracer, Rails::Rack::Tracer)
|
68
|
-
```
|
69
|
-
|
70
|
-
or simpler
|
71
|
-
|
72
|
-
```ruby
|
73
|
-
Rails::Rack::Tracer.instrument
|
74
|
-
```
|
75
|
-
|
76
|
-
optionally you can pass `tracer` argument to `instrument` method.
|
77
|
-
|
78
|
-
## ActiveRecord
|
79
|
-
|
80
|
-
The library hooks up into Rails using `ActiveSupport::Notifications`, and instruments all `ActiveRecord` query.
|
81
|
-
|
82
|
-
### Usage
|
83
|
-
|
84
|
-
Auto-instrumentation example.
|
85
|
-
|
86
|
-
```ruby
|
87
|
-
require 'rails/tracer'
|
88
|
-
|
89
|
-
ActiveRecord::Tracer.instrument(tracer: OpenTracing.global_tracer,
|
90
|
-
active_span: -> { OpenTracing.global_tracer.active_span })
|
91
|
-
```
|
92
|
-
|
93
|
-
There are times when you might want to skip ActiveRecord's magic, and use connection directly. Still the library
|
94
|
-
can help you with span creation. Instead of auto-instrumenting you can manually call `ActiveRecord::Tracer.start_span` as shown below.
|
26
|
+
## Usage
|
95
27
|
|
96
28
|
```ruby
|
97
|
-
|
98
|
-
span = ActiveRecord::Tracer.start_span(name,
|
99
|
-
tracer: OpenTracing.global_tracer,
|
100
|
-
active_span: -> { OpenTracing.global_tracer.active_span },
|
101
|
-
sql: sql)
|
102
|
-
ActiveRecord::Base.
|
103
|
-
connection.
|
104
|
-
raw_connection.
|
105
|
-
query(sql).
|
106
|
-
each(as: :hash)
|
107
|
-
ensure
|
108
|
-
span&.finish
|
109
|
-
end
|
110
|
-
|
111
|
-
q("FirstUser", "SELECT * FROM users LIMIT 1")
|
112
|
-
```
|
113
|
-
|
114
|
-
## ActiveSupport::Cache
|
115
|
-
|
116
|
-
The library hooks up into Rails using `ActiveSupport::Notifications`, and instruments all `ActiveSupport::Cache` events.
|
117
|
-
|
118
|
-
### Usage
|
29
|
+
require 'rails/instrumentation'
|
119
30
|
|
120
|
-
|
31
|
+
tracer_impl = SomeTracerImplementation.new
|
121
32
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
ActiveSupport::Cache::Tracer.instrument(tracer: OpenTracing.global_tracer,
|
126
|
-
active_span: -> { OpenTracing.global_tracer.active_span })
|
33
|
+
Rails::Instrumentation.instrument(tracer: tracer,
|
34
|
+
exclude_events: [])
|
127
35
|
```
|
128
36
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
If you want to skip the auto-instrumentation, still the library can help you with span creation and setting up proper tags. Instead of auto-instrumenting, as shown above, you can manually call `ActiveSupport::Cache::Tracer.start_span` as shown below.
|
138
|
-
|
139
|
-
```ruby
|
140
|
-
def read(key)
|
141
|
-
span = ActiveSupport::Cache::Tracer.start_span("InMemoryCache#read",
|
142
|
-
tracer: OpenTracing.global_tracer,
|
143
|
-
active_span: -> { OpenTracing.global_tracer.active_span },
|
144
|
-
key: key)
|
145
|
-
result = in_memory_cache[key]
|
146
|
-
span.set_tag('cache.hit', !!result)
|
147
|
-
result
|
148
|
-
ensure
|
149
|
-
span&.finish
|
150
|
-
end
|
151
|
-
|
152
|
-
read("user-1")
|
153
|
-
```
|
154
|
-
|
155
|
-
## ActionController
|
156
|
-
|
157
|
-
This instruments `start_processing` and `process_action` events using `ActiveSupport::Notifications` to get important information about a request once it has finished.
|
37
|
+
`instrument` takes these optional named arguments:
|
38
|
+
- `tracer`: OpenTracing tracer to be used for this instrumentation
|
39
|
+
- Default: `OpenTracing.global_tracer`
|
40
|
+
- `exclude_events`: Some events may be too noisy or they may simply not be
|
41
|
+
necessary. These can be passed in as an array, and the instrumentation will
|
42
|
+
not subscribe to those events. The available events can be found in the [Instrumented Events](#instrumented-events) section.
|
43
|
+
- Default: `[]`
|
44
|
+
- Example: `['sql.active_record', 'read_fragment.action_controller']`
|
158
45
|
|
159
|
-
|
160
|
-
|
161
|
-
Auto-instrumentation example.
|
46
|
+
All instrumentation can be removed:
|
162
47
|
|
163
48
|
```ruby
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
49
|
+
Rails::Instrumentation.uninstrument
|
50
|
+
```
|
51
|
+
|
52
|
+
This will clear all subscribers registered by this instrumentation.
|
53
|
+
|
54
|
+
## Instrumented Events
|
55
|
+
|
56
|
+
Events that have additional useful information in the payload will have additional
|
57
|
+
tags on their span, as listed below.
|
58
|
+
|
59
|
+
For more information about each event, please look at the ActiveSupport
|
60
|
+
notifications [documentation](https://guides.rubyonrails.org/active_support_instrumentation.html).
|
61
|
+
|
62
|
+
### Action Controller
|
63
|
+
|
64
|
+
| Event | Span Tag Names |
|
65
|
+
| --- | --- |
|
66
|
+
| write_fragment.action_controller | key.write |
|
67
|
+
| read_fragment.action_controller | key.read |
|
68
|
+
| expire_fragment.action_controller | key.expire |
|
69
|
+
| exist_fragment?.action_controller | key.exist |
|
70
|
+
| write_page.action_controller | path.write |
|
71
|
+
| expire_page.action_controller | path.expire |
|
72
|
+
| start_processing.action_controller | controller<br> controller.action<br> request.params<br> request.format<br> http.method<br> http.url |
|
73
|
+
| process_action.action_controller | controller<br> controller.action<br> request.params<br> request.format<br> http.method<br> http.url<br> http.status_code<br> view.runtime_ms<br> db.runtime_ms |
|
74
|
+
| send_file.action_controller | path.send |
|
75
|
+
| send_data.action_controller | |
|
76
|
+
| redirect_to.action_controller | http.status_code<br> redirect.url |
|
77
|
+
| halted_callback.action_controller | filter |
|
78
|
+
| unpermitted_parameters.action_controller | unpermitted_keys |
|
79
|
+
### Action View
|
80
|
+
|
81
|
+
| Event | Span Tag Names |
|
82
|
+
| --- | --- |
|
83
|
+
| render_tempate.action_view | template.identifier<br> template.layout |
|
84
|
+
| render_partial.action_view | partial.identifier |
|
85
|
+
| render_collection.action_view | template.identifier<br> template.count<br> template.cache_hits |
|
86
|
+
|
87
|
+
### Active Record
|
88
|
+
|
89
|
+
| Event | Span Tag Names |
|
90
|
+
| --- | --- |
|
91
|
+
| sql.active_record | db.statement<br> name<br> connection_id<br> binds<br> cached |
|
92
|
+
| instantiation.active_record | record.count<br> record.class |
|
93
|
+
|
94
|
+
### Action Mailer
|
95
|
+
|
96
|
+
| Event | Span Tag Names |
|
97
|
+
| --- | --- |
|
98
|
+
| receive.action_mailer | mailer<br> message.id<br> message.subject<br> message.to<br> message.from<br> message.bcc<br> message.cc<br> message.date<br> message.body |
|
99
|
+
| deliver.action_mailer | mailer<br> message.id<br> message.subject<br> message.to<br> message.from<br> message.bcc<br> message.cc<br> message.date<br> message.body |
|
100
|
+
| process.action_mailer | mailer<br> action<br> args |
|
101
|
+
|
102
|
+
### Active Support
|
103
|
+
|
104
|
+
| Event | Span Tag Names |
|
105
|
+
| --- | --- |
|
106
|
+
| cache_read.active_support | key<br> hit<br> super_operation |
|
107
|
+
| cache_generate.active_support | key |
|
108
|
+
| cache_fetch_hit.active_support | key |
|
109
|
+
| cache_write.active_support | key |
|
110
|
+
| cache_delete.active_support | key |
|
111
|
+
| cache_exist?.active_support | key |
|
112
|
+
|
113
|
+
### Active Job
|
114
|
+
|
115
|
+
| Event | Span Tag Names |
|
116
|
+
| --- | --- |
|
117
|
+
| enqueue_at.active_job | adapter<br> job |
|
118
|
+
| enqueue.active_job | adapter<br> job |
|
119
|
+
| perform_start.active_job | adapter<br> job |
|
120
|
+
| perform.active_job | adapter<br> job |
|
121
|
+
|
122
|
+
### Action Cable
|
123
|
+
|
124
|
+
| Event | Span Tag Names |
|
125
|
+
| --- | --- |
|
126
|
+
| perform_action.action_cable | channel_class<br> action<br> data |
|
127
|
+
| transmit.action_cable | channel_class<br> data<br> via |
|
128
|
+
| transmit_subscription_confirmation.action_cable | channel_class |
|
129
|
+
| transmit_subscription_rejection.action_cable | channel_class |
|
130
|
+
| broadcast.action_cable | broadcasting<br> message<br> coder |
|
131
|
+
|
132
|
+
### Active Storage
|
133
|
+
|
134
|
+
| Event | Span Tag Names |
|
135
|
+
| --- | --- |
|
136
|
+
| service_upload.active_storage | key<br> service<br> checksum |
|
137
|
+
| service_streaming_download.active_storage | key<br> service |
|
138
|
+
| service_download.active_storage | key<br> service |
|
139
|
+
| service_delete.active_storage | key<br> service |
|
140
|
+
| service_delete_prefixed.active_storage | key.prefix<br> service |
|
141
|
+
| service_exist.active_storage | key<br> service<br> exist |
|
142
|
+
| service_url.active_storage | key<br> service<br> url |
|
169
143
|
|
170
144
|
## Development
|
171
145
|
|
172
|
-
After checking out the repo, install dependencies.
|
173
|
-
|
174
|
-
```
|
175
|
-
bundle install
|
176
|
-
appraisal install
|
177
|
-
```
|
178
|
-
|
179
|
-
The tests depends on having memcached running locally within docker container. It means you need to install docker, and docker-compose first.
|
180
|
-
Once you're done to run the containers:
|
181
|
-
|
182
|
-
```
|
183
|
-
docker-compose up -d
|
184
|
-
```
|
185
|
-
|
186
|
-
Then, to run tests for all appraisals:
|
187
|
-
|
188
|
-
```
|
189
|
-
appraisal bundle exec rspec spec
|
190
|
-
```
|
191
|
-
|
192
|
-
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
146
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
193
147
|
|
194
|
-
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
148
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
195
149
|
|
196
150
|
## Contributing
|
197
151
|
|
198
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
152
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/signalfx/ruby-rails-instrumentation.
|