influxdb-rails 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/rubocop.yml +18 -0
- data/.github/workflows/spec.yml +32 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +35 -7
- data/CHANGELOG.md +40 -1
- data/README.md +125 -27
- data/Rakefile +0 -6
- data/gemfiles/Gemfile.rails-6.0.x +9 -0
- data/gemfiles/Gemfile.rails-6.1.x +9 -0
- data/influxdb-rails.gemspec +7 -4
- data/lib/influxdb-rails.rb +13 -2
- data/lib/influxdb/rails/configuration.rb +8 -12
- data/lib/influxdb/rails/context.rb +6 -40
- data/lib/influxdb/rails/helpers/rspec_matchers.rb +48 -0
- data/lib/influxdb/rails/metric.rb +39 -0
- data/lib/influxdb/rails/middleware/action_mailer_subscriber.rb +22 -0
- data/lib/influxdb/rails/middleware/active_job_subscriber.rb +67 -0
- data/lib/influxdb/rails/middleware/active_record_subscriber.rb +26 -0
- data/lib/influxdb/rails/middleware/block_instrumentation_subscriber.rb +24 -0
- data/lib/influxdb/rails/middleware/render_subscriber.rb +15 -16
- data/lib/influxdb/rails/middleware/request_subscriber.rb +16 -21
- data/lib/influxdb/rails/middleware/sql_subscriber.rb +18 -18
- data/lib/influxdb/rails/middleware/subscriber.rb +40 -27
- data/lib/influxdb/rails/railtie.rb +15 -18
- data/lib/influxdb/rails/sql/normalizer.rb +3 -3
- data/lib/influxdb/rails/tags.rb +33 -0
- data/lib/influxdb/rails/test_client.rb +13 -0
- data/lib/influxdb/rails/values.rb +24 -0
- data/lib/influxdb/rails/version.rb +1 -1
- data/lib/rails/generators/influxdb/templates/initializer.rb +4 -0
- data/sample-dashboard/Dockerfile +2 -2
- data/sample-dashboard/README.md +21 -28
- data/sample-dashboard/Rakefile +10 -5
- data/sample-dashboard/Ruby On Rails ActiveJob.json +600 -0
- data/sample-dashboard/{Ruby On Rails Performance (per Action).json → Ruby On Rails Performance per Action.json } +343 -589
- data/sample-dashboard/{Ruby On Rails Performance (per Request).json → Ruby On Rails Performance per Request.json } +361 -211
- data/sample-dashboard/Ruby On Rails Performance.json +1347 -1139
- data/sample-dashboard/Ruby On Rails Requests.json +834 -0
- data/sample-dashboard/Ruby On Rails Slowlog by Action.json +278 -0
- data/sample-dashboard/Ruby On Rails Slowlog by Request.json +277 -0
- data/sample-dashboard/Ruby On Rails Slowlog by SQL.json +328 -0
- data/sample-dashboard/docker-compose.yml +6 -1
- data/sample-dashboard/provisioning/activejob.json +600 -0
- data/sample-dashboard/provisioning/performance-action.json +334 -580
- data/sample-dashboard/provisioning/performance-request.json +355 -205
- data/sample-dashboard/provisioning/performance.json +1336 -1128
- data/sample-dashboard/provisioning/requests.json +834 -0
- data/sample-dashboard/provisioning/slowlog-action.json +278 -0
- data/sample-dashboard/provisioning/slowlog-requests.json +277 -0
- data/sample-dashboard/provisioning/slowlog-sql.json +328 -0
- data/spec/requests/action_controller_metrics_spec.rb +96 -0
- data/spec/requests/action_mailer_deliver_metrics_spec.rb +42 -0
- data/spec/requests/action_view_collection_metrics_spec.rb +57 -0
- data/spec/requests/action_view_partial_metrics_spec.rb +53 -0
- data/spec/requests/action_view_template_metrics_spec.rb +53 -0
- data/spec/requests/active_job_enqueue_metrics_spec.rb +56 -0
- data/spec/requests/active_job_perform_metrics_spec.rb +62 -0
- data/spec/requests/active_record_instantiation_metrics_spec.rb +56 -0
- data/spec/requests/active_record_sql_metrics_spec.rb +87 -0
- data/spec/requests/block_inistrumentation_spec.rb +55 -0
- data/spec/requests/context_spec.rb +27 -0
- data/spec/requests/logger_spec.rb +10 -0
- data/spec/spec_helper.rb +12 -4
- data/spec/support/broken_client.rb +11 -0
- data/spec/support/rails5/app.rb +48 -13
- data/spec/support/rails6/app.rb +83 -0
- data/spec/support/views/layouts/mailer.txt.erb +1 -0
- data/spec/support/views/{widgets → metrics}/_item.html.erb +0 -0
- data/spec/support/views/{widgets → metrics}/index.html.erb +0 -0
- data/spec/support/views/metrics/show.html.erb +4 -0
- data/spec/unit/block_instrumentation_spec.rb +18 -0
- data/spec/unit/tags.rb +47 -0
- metadata +123 -45
- data/.travis.yml +0 -37
- data/gemfiles/Gemfile.rails-4.2.x +0 -7
- data/gemfiles/Gemfile.rails-5.0.x +0 -7
- data/gemfiles/Gemfile.rails-5.1.x +0 -7
- data/lib/influxdb/rails/instrumentation.rb +0 -34
- data/lib/influxdb/rails/middleware/simple_subscriber.rb +0 -33
- data/spec/controllers/widgets_controller_spec.rb +0 -15
- data/spec/integration/integration_helper.rb +0 -1
- data/spec/integration/metrics_spec.rb +0 -27
- data/spec/shared_examples/data.rb +0 -61
- data/spec/support/rails4/app.rb +0 -48
- data/spec/unit/context_spec.rb +0 -40
- data/spec/unit/middleware/render_subscriber_spec.rb +0 -96
- data/spec/unit/middleware/request_subscriber_spec.rb +0 -103
- data/spec/unit/middleware/sql_subscriber_spec.rb +0 -108
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd28d1ed1a585a6ad1aef9945e693b2b1d20668de731e35ab0066c2c09ed50a5
|
4
|
+
data.tar.gz: df3e81593ce080e308018b2f94ea4ff4e3094f3584843051c60d6219ed9fe7aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cbea1f68ee5ad8b68f9b8a4ee953999215bf62f6300aff3fb7b679f6d5fa797a49a2c28f9d0d2f0594f14cc15955d34291b6344371ad141d107d6dc8ff7a8c2
|
7
|
+
data.tar.gz: 6723fc68b1ba75a1efd39e820e9752e757bbb34007763b832ea565942716606a6ee388bfdb967dbabd4790eefb9b7414e6dc0697b7d6388454713b4b879700f6
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: Rubocop
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
rubocop:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: 2.7
|
17
|
+
bundler-cache: true
|
18
|
+
- run: bundle exec rake rubocop
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: Specs
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
spec:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby: [ '2.5', '2.6', '2.7', '3.0', 'head' ]
|
15
|
+
rails: [ 'gemfiles/Gemfile.rails-6.1.x', 'gemfiles/Gemfile.rails-6.0.x', 'gemfiles/Gemfile.rails-5.2.x']
|
16
|
+
exclude:
|
17
|
+
- { ruby: '2.7', rails: 'gemfiles/Gemfile.rails-5.2.x' }
|
18
|
+
- { ruby: '3.0', rails: 'gemfiles/Gemfile.rails-5.2.x' }
|
19
|
+
- { ruby: 'head', rails: 'gemfiles/Gemfile.rails-5.2.x' }
|
20
|
+
- { ruby: '2.5', rails: 'gemfiles/Gemfile.rails-6.0.x' }
|
21
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
22
|
+
env:
|
23
|
+
BUNDLE_GEMFILE: ${{ matrix.rails }}
|
24
|
+
name: Ruby ${{ matrix.ruby }} ${{ matrix.rails }} specs
|
25
|
+
steps:
|
26
|
+
- uses: actions/checkout@v2
|
27
|
+
- uses: ruby/setup-ruby@v1
|
28
|
+
with:
|
29
|
+
ruby-version: ${{ matrix.ruby }}
|
30
|
+
bundler-cache: true
|
31
|
+
- name: Run tests
|
32
|
+
run: bundle exec rake spec
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -11,10 +11,7 @@ AllCops:
|
|
11
11
|
- 'vendor/bundle/**/*'
|
12
12
|
DisplayCopNames: true
|
13
13
|
StyleGuideCopsOnly: false
|
14
|
-
TargetRubyVersion: 2.
|
15
|
-
|
16
|
-
Rails:
|
17
|
-
Enabled: false
|
14
|
+
TargetRubyVersion: 2.4
|
18
15
|
|
19
16
|
Layout/EmptyLinesAroundArguments:
|
20
17
|
Enabled: false
|
@@ -22,7 +19,7 @@ Layout/EmptyLinesAroundArguments:
|
|
22
19
|
Layout/SpaceBeforeBlockBraces:
|
23
20
|
EnforcedStyleForEmptyBraces: space
|
24
21
|
|
25
|
-
Layout/
|
22
|
+
Layout/HashAlignment:
|
26
23
|
EnforcedColonStyle: table
|
27
24
|
EnforcedHashRocketStyle: table
|
28
25
|
|
@@ -34,7 +31,7 @@ Metrics/BlockLength:
|
|
34
31
|
- 'spec/**/*.rb'
|
35
32
|
- 'influxdb-rails.gemspec'
|
36
33
|
|
37
|
-
|
34
|
+
Layout/LineLength:
|
38
35
|
Max: 100
|
39
36
|
Exclude:
|
40
37
|
- 'spec/**/*.rb'
|
@@ -46,7 +43,7 @@ Metrics/ModuleLength:
|
|
46
43
|
Metrics/ParameterLists:
|
47
44
|
Max: 6
|
48
45
|
|
49
|
-
Naming/
|
46
|
+
Naming/MethodParameterName:
|
50
47
|
AllowedNames: [io, id, db, ex]
|
51
48
|
|
52
49
|
Naming/FileName:
|
@@ -81,3 +78,34 @@ Style/TrailingCommaInHashLiteral:
|
|
81
78
|
EnforcedStyleForMultiline: comma
|
82
79
|
Exclude:
|
83
80
|
- "spec/**/*.rb"
|
81
|
+
|
82
|
+
Lint/DuplicateBranch:
|
83
|
+
Enabled: true
|
84
|
+
Lint/DuplicateRegexpCharacterClassElement:
|
85
|
+
Enabled: true
|
86
|
+
Lint/EmptyBlock:
|
87
|
+
Enabled: true
|
88
|
+
Lint/EmptyClass:
|
89
|
+
Enabled: true
|
90
|
+
Lint/NoReturnInBeginEndBlocks:
|
91
|
+
Enabled: true
|
92
|
+
Lint/ToEnumArguments:
|
93
|
+
Enabled: true
|
94
|
+
Lint/UnexpectedBlockArity:
|
95
|
+
Enabled: true
|
96
|
+
Lint/UnmodifiedReduceAccumulator:
|
97
|
+
Enabled: true
|
98
|
+
Style/ArgumentsForwarding:
|
99
|
+
Enabled: true
|
100
|
+
Style/CollectionCompact:
|
101
|
+
Enabled: true
|
102
|
+
Style/DocumentDynamicEvalDefinition:
|
103
|
+
Enabled: true
|
104
|
+
Style/NegatedIfElseCondition:
|
105
|
+
Enabled: true
|
106
|
+
Style/NilLambda:
|
107
|
+
Enabled: true
|
108
|
+
Style/RedundantArgument:
|
109
|
+
Enabled: true
|
110
|
+
Style/SwapValues:
|
111
|
+
Enabled: true
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,47 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
For the full commit log, [see here](https://github.com/influxdata/influxdb-rails/commits/
|
3
|
+
For the full commit log, [see here](https://github.com/influxdata/influxdb-rails/commits/one-stable).
|
4
|
+
|
5
|
+
## v1.0.2, released 2021-04-13
|
6
|
+
|
7
|
+
Fix passing booleans to custom tags.
|
8
|
+
|
9
|
+
## v1.0.1, released 2021-03-23
|
10
|
+
|
11
|
+
The final release, no code changes.
|
12
|
+
|
13
|
+
## v1.0.1.beta3, released 2020-10-16
|
14
|
+
|
15
|
+
- Drop `perform_start.active_job` subscriber, it's rather useless on dashboards.
|
16
|
+
|
17
|
+
## v1.0.1.beta2, released 2020-09-14
|
18
|
+
|
19
|
+
- Implement [`deliver.action_mailer`](https://guides.rubyonrails.org/active_support_instrumentation.html#deliver-action-mailer) subscriber
|
20
|
+
- Add missing Active Job documentation
|
21
|
+
- Drop support for Ruby 2.4
|
22
|
+
- Drop support for Rails < 5.2
|
23
|
+
|
24
|
+
## v1.0.1.beta1, released 2020-08-21
|
25
|
+
|
26
|
+
- Drop support for Ruby 2.3
|
27
|
+
- Drop support for Rails 4.x
|
28
|
+
- Add `auth_method` to client configuration (#96, @anlek)
|
29
|
+
- Drop undocumented `instrumentation_enabled` setting, use
|
30
|
+
`ignored_environments` do disable instrumentation
|
31
|
+
- Simplified spec with a PORO test client
|
32
|
+
- Implement `instantiation.active_record` subscriber (https://guides.rubyonrails.org/active_support_instrumentation.html#instantiation-active-record)
|
33
|
+
- Implement `enqueue.active_job` subscriber (https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-active-job)
|
34
|
+
- Implement `perform_start.active_job` subscriber (https://guides.rubyonrails.org/active_support_instrumentation.html#perform-start-active-job)
|
35
|
+
- Implement `perform.active_job` subscriber (https://guides.rubyonrails.org/active_support_instrumentation.html#perform-active-job)
|
36
|
+
- Implement block instrumentation `InfluxDB::Rails.instrument do; 1 + 1; end`
|
37
|
+
- Record unhandled exceptions as tags for process_action.action_controller
|
38
|
+
|
39
|
+
## v1.0.0, released 2019-10-23
|
40
|
+
|
41
|
+
The Final release, no code changes.
|
4
42
|
|
5
43
|
## v1.0.0.beta5, unreleased
|
44
|
+
|
6
45
|
- Silently eat all dropped configuration options and do not crash
|
7
46
|
- Add per action view to the sample dashboard
|
8
47
|
|
data/README.md
CHANGED
@@ -1,17 +1,14 @@
|
|
1
|
-
> You are looking at the README for the master branch of this gem.
|
2
|
-
>
|
3
|
-
>
|
4
|
-
> for an online version.
|
1
|
+
> :warning: You are looking at the README for the master branch of this gem.
|
2
|
+
> See the latest [released version (1.0.1)](https://github.com/influxdata/influxdb-rails/tree/v1.0.1#readme)
|
3
|
+
> instead.
|
5
4
|
|
6
5
|
# influxdb-rails
|
7
6
|
|
8
7
|
[![Gem Version](https://badge.fury.io/rb/influxdb-rails.svg)](https://badge.fury.io/rb/influxdb-rails)
|
9
|
-
[![Build Status](https://
|
8
|
+
[![Build Status](https://github.com/influxdata/influxdb-rails/actions/workflows/spec.yml/badge.svg)](https://github.com/influxdata/influxdb-rails/actions)
|
10
9
|
|
11
|
-
Automatically instrument your Ruby on Rails applications and write the
|
12
|
-
|
13
|
-
|
14
|
-
This gem is designed for Rails 4.2+, Ruby 2.3+ and InfluxDB 0.9+.
|
10
|
+
Automatically instrument your Ruby on Rails applications and write the metrics directly into
|
11
|
+
[InfluxDB](https://www.influxdata.com/).
|
15
12
|
|
16
13
|
## Table of contents
|
17
14
|
|
@@ -42,8 +39,8 @@ configuration of this gem.
|
|
42
39
|
|
43
40
|
## Usage
|
44
41
|
|
45
|
-
Out of the box, you'll automatically get reporting for
|
46
|
-
|
42
|
+
Out of the box, you'll automatically get reporting for the Ruby on Rails components mentioned
|
43
|
+
below.
|
47
44
|
|
48
45
|
### Action Controller
|
49
46
|
|
@@ -56,9 +53,9 @@ Reported values:
|
|
56
53
|
|
57
54
|
```ruby
|
58
55
|
controller: 48.467,
|
59
|
-
view: 46.848
|
56
|
+
view: 46.848,
|
60
57
|
db: 0.157,
|
61
|
-
started: 1465839830100400200
|
58
|
+
started: 1465839830100400200,
|
62
59
|
request_id: "d5bf620b-3494-425b-b7e1-4953597ea744"
|
63
60
|
```
|
64
61
|
|
@@ -72,10 +69,13 @@ Reported tags:
|
|
72
69
|
method: "PostsController#index",
|
73
70
|
http_method: "GET",
|
74
71
|
format: "html",
|
75
|
-
status: "200"
|
72
|
+
status: ["200", ""],
|
73
|
+
exception: "ArgumentError"
|
76
74
|
}
|
77
75
|
```
|
78
76
|
|
77
|
+
*Note*: If an exception happens during that particular action the `status` will be blank and the tag `exception` will contain the name of the exception class. The status is blank because we can't know how you handle the exception outside the action.
|
78
|
+
|
79
79
|
### Action View
|
80
80
|
|
81
81
|
Reported ActiveSupport instrumentation hooks:
|
@@ -96,11 +96,11 @@ Reported values:
|
|
96
96
|
Reported tags:
|
97
97
|
|
98
98
|
```ruby
|
99
|
-
hook: ["render_template", "render_partial", "render_collection"]
|
99
|
+
hook: ["render_template", "render_partial", "render_collection"],
|
100
100
|
server: Socket.gethostname,
|
101
101
|
app_name: configuration.application_name,
|
102
102
|
location: "PostsController#index",
|
103
|
-
filename: "/some/file/action.html"
|
103
|
+
filename: "/some/file/action.html"
|
104
104
|
```
|
105
105
|
|
106
106
|
### Active Record
|
@@ -108,15 +108,16 @@ Reported tags:
|
|
108
108
|
Reported ActiveSupport instrumentation hooks:
|
109
109
|
|
110
110
|
- [sql.active\_record](https://guides.rubyonrails.org/active_support_instrumentation.html#sql-active-record)
|
111
|
+
- [instantiation.active\_record](https://guides.rubyonrails.org/active_support_instrumentation.html#instantiation-active-record)
|
111
112
|
|
112
|
-
Reported values:
|
113
|
+
Reported SQL values:
|
113
114
|
|
114
115
|
```ruby
|
115
116
|
sql: "SELECT \"posts\".* FROM \"posts\"",
|
116
117
|
request_id: "d5bf620b-3494-425b-b7e1-4953597ea744"
|
117
118
|
```
|
118
119
|
|
119
|
-
Reported tags:
|
120
|
+
Reported SQL tags:
|
120
121
|
|
121
122
|
```ruby
|
122
123
|
hook: "sql",
|
@@ -128,6 +129,70 @@ Reported tags:
|
|
128
129
|
name: "Post Load"
|
129
130
|
```
|
130
131
|
|
132
|
+
Reported instantiation values:
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
record_count: 1,
|
136
|
+
request_id: "d5bf620b-3494-425b-b7e1-4953597ea744"
|
137
|
+
value: 7.689
|
138
|
+
```
|
139
|
+
|
140
|
+
Reported instantiation tags:
|
141
|
+
|
142
|
+
```ruby
|
143
|
+
hook: "instantiation",
|
144
|
+
server: Socket.gethostname,
|
145
|
+
app_name: configuration.application_name,
|
146
|
+
location: "PostsController#index",
|
147
|
+
class_name: "POST"
|
148
|
+
```
|
149
|
+
|
150
|
+
### Active Job
|
151
|
+
|
152
|
+
Reported ActiveSupport instrumentation hooks:
|
153
|
+
|
154
|
+
- [enqueue.active\_job](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-active-job)
|
155
|
+
- [perform.active\_job](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-active-job)
|
156
|
+
|
157
|
+
Reported values:
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
value: 89.467
|
161
|
+
```
|
162
|
+
|
163
|
+
Reported tags:
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
hook: ["enqueue", "perform"],
|
167
|
+
state: ["queued", "succeeded", "failed"],
|
168
|
+
job: "SomeJobClassName",
|
169
|
+
queue: "queue_name"
|
170
|
+
```
|
171
|
+
|
172
|
+
*Note*: Only the measurements with the hook `perform` report a duration in the value.
|
173
|
+
The enqueue hook is a counter and always reports a value of `1`.
|
174
|
+
|
175
|
+
### Action Mailer
|
176
|
+
|
177
|
+
Reported ActiveSupport instrumentation hooks:
|
178
|
+
|
179
|
+
- [deliver.action\_mailer](https://guides.rubyonrails.org/active_support_instrumentation.html#deliver-action-mailer)
|
180
|
+
|
181
|
+
Reported values:
|
182
|
+
|
183
|
+
```ruby
|
184
|
+
value: 1
|
185
|
+
```
|
186
|
+
|
187
|
+
Reported tags:
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
hook: "deliver",
|
191
|
+
mailer: "SomeMailerClassName"
|
192
|
+
```
|
193
|
+
|
194
|
+
*Note*: The hook is just a counter and always report a value of `1`.
|
195
|
+
|
131
196
|
## Configuration
|
132
197
|
|
133
198
|
The only setting you actually need to configure is the name of the database
|
@@ -139,9 +204,7 @@ InfluxDB::Rails.configure do |config|
|
|
139
204
|
end
|
140
205
|
```
|
141
206
|
|
142
|
-
You'll find
|
143
|
-
canonical list of default values is located in `lib/influxdb/rails/configuration.rb`
|
144
|
-
(`InfluxDB::Rails::Configuration::DEFAULTS`).
|
207
|
+
You'll find all of the configuration settings in the initializer file.
|
145
208
|
|
146
209
|
### Custom Tags
|
147
210
|
|
@@ -177,6 +240,44 @@ class ApplicationController
|
|
177
240
|
end
|
178
241
|
```
|
179
242
|
|
243
|
+
### Block Instrumentation
|
244
|
+
If you want to add custom instrumentation, you can wrap any code into a block instrumentation
|
245
|
+
|
246
|
+
```ruby
|
247
|
+
InfluxDB::Rails.instrument "expensive_operation", tags: { }, values: { } do
|
248
|
+
expensive_operation
|
249
|
+
end
|
250
|
+
```
|
251
|
+
|
252
|
+
Reported tags:
|
253
|
+
|
254
|
+
```ruby
|
255
|
+
hook: "block_instrumentation",
|
256
|
+
server: Socket.gethostname,
|
257
|
+
app_name: configuration.application_name,
|
258
|
+
location: "PostsController#index",
|
259
|
+
name: "expensive_operation"
|
260
|
+
```
|
261
|
+
|
262
|
+
Reported values:
|
263
|
+
```ruby
|
264
|
+
value: 100 # execution time of the block in ms
|
265
|
+
```
|
266
|
+
|
267
|
+
You can also overwrite the `value`
|
268
|
+
|
269
|
+
```ruby
|
270
|
+
InfluxDB::Rails.instrument "user_count", values: { value: 1 } do
|
271
|
+
User.create(name: 'mickey', surname: 'mouse')
|
272
|
+
end
|
273
|
+
```
|
274
|
+
|
275
|
+
or call it even without a block
|
276
|
+
|
277
|
+
```ruby
|
278
|
+
InfluxDB::Rails.instrument "temperature", values: { value: 25 }
|
279
|
+
```
|
280
|
+
|
180
281
|
### Custom client configuration
|
181
282
|
|
182
283
|
The settings named `config.client.*` are used to construct an `InfluxDB::Client`
|
@@ -243,7 +344,7 @@ might cause performance issues on traffic intensive applications. Disable it in
|
|
243
344
|
the configuration if you are not willing to tolerate this.
|
244
345
|
|
245
346
|
By default, this gem performs writes to InfluxDB asynchronously. A single
|
246
|
-
|
347
|
+
hook usually only performs some time delta calculations, and then enqueues
|
247
348
|
the data point into a worker queue (which is processed by a background
|
248
349
|
thread).
|
249
350
|
|
@@ -267,8 +368,7 @@ implications, depending on the value of `config.client.async`:
|
|
267
368
|
cycle), it might block all available request threads
|
268
369
|
|
269
370
|
In both cases, your application server might become unresponsive and needs
|
270
|
-
to be restarted
|
271
|
-
like Docker containers).
|
371
|
+
to be restarted.
|
272
372
|
|
273
373
|
If you setup a maximum retry value (`Integer === config.client.retry`),
|
274
374
|
the client will try up to that amount of times to send the data to the server
|
@@ -299,13 +399,11 @@ The data points are simply discarded.
|
|
299
399
|
rake test:all
|
300
400
|
```
|
301
401
|
|
302
|
-
- or wait for [
|
402
|
+
- or wait for [our CI](https://github.com/influxdata/influxdb-rails/actions) to pick up your changes, *after*
|
303
403
|
you made a pull request.
|
304
404
|
- Send a pull request.
|
305
405
|
- If your changes are looking good, we'll merge them.
|
306
406
|
|
307
|
-
[travis-pr]: https://travis-ci.org/influxdata/influxdb-rails/pull_requests
|
308
|
-
|
309
407
|
### Testing Tasks
|
310
408
|
|
311
409
|
```console
|