influxdb-rails 1.0.0.beta3 → 1.0.0.beta4
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/.rubocop.yml +5 -0
- data/CHANGELOG.md +12 -10
- data/README.md +193 -168
- data/influxdb-rails.gemspec +13 -7
- data/lib/influxdb/rails/configuration.rb +88 -192
- data/lib/influxdb/rails/context.rb +19 -1
- data/lib/influxdb/rails/instrumentation.rb +4 -4
- data/lib/influxdb/rails/middleware/render_subscriber.rb +7 -0
- data/lib/influxdb/rails/middleware/request_subscriber.rb +22 -24
- data/lib/influxdb/rails/middleware/simple_subscriber.rb +12 -25
- data/lib/influxdb/rails/middleware/sql_subscriber.rb +7 -3
- data/lib/influxdb/rails/middleware/subscriber.rb +19 -8
- data/lib/influxdb/rails/railtie.rb +29 -32
- data/lib/influxdb/rails/version.rb +1 -1
- data/lib/influxdb-rails.rb +20 -81
- data/lib/rails/generators/influxdb/influxdb_generator.rb +1 -1
- data/lib/rails/generators/influxdb/templates/initializer.rb +39 -9
- data/sample-dashboard/Dockerfile +25 -0
- data/sample-dashboard/README.md +74 -0
- data/sample-dashboard/Rakefile +8 -0
- data/sample-dashboard/Ruby On Rails Performance (per Request).json +1053 -0
- data/sample-dashboard/Ruby On Rails Performance.json +2011 -0
- data/sample-dashboard/docker-compose.yml +33 -0
- data/sample-dashboard/provisioning/grafana-dashboards.yml +12 -0
- data/sample-dashboard/provisioning/grafana-datasource.yml +10 -0
- data/sample-dashboard/provisioning/performance-request.json +1053 -0
- data/sample-dashboard/provisioning/performance.json +2011 -0
- data/spec/integration/metrics_spec.rb +12 -13
- data/spec/shared_examples/data.rb +61 -0
- data/spec/spec_helper.rb +3 -1
- data/spec/support/rails4/app.rb +4 -0
- data/spec/support/rails5/app.rb +4 -0
- data/spec/unit/configuration_spec.rb +47 -65
- data/spec/unit/middleware/render_subscriber_spec.rb +13 -9
- data/spec/unit/middleware/request_subscriber_spec.rb +33 -21
- data/spec/unit/middleware/sql_subscriber_spec.rb +35 -8
- metadata +42 -30
- data/lib/influxdb/rails/air_traffic_controller.rb +0 -41
- data/lib/influxdb/rails/backtrace.rb +0 -44
- data/lib/influxdb/rails/exception_presenter.rb +0 -94
- data/lib/influxdb/rails/logger.rb +0 -16
- data/lib/influxdb/rails/middleware/hijack_render_exception.rb +0 -16
- data/lib/influxdb/rails/middleware/hijack_rescue_action_everywhere.rb +0 -31
- data/lib/influxdb/rails/rack.rb +0 -24
- data/spec/integration/exceptions_spec.rb +0 -37
- data/spec/shared_examples/tags.rb +0 -42
- data/spec/unit/backtrace_spec.rb +0 -85
- data/spec/unit/exception_presenter_spec.rb +0 -23
- data/spec/unit/influxdb_rails_spec.rb +0 -78
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2461ed02fc4166901dc276517fc631e5adc65f80c0dd3443e76c2339432315d9
|
4
|
+
data.tar.gz: 2e7073aeb190f52ac858696a52c92078dbe685282ff7689ac477dd9bc20cfa90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fba1e70ddf5caf88cb5432788339a0a311c742a990700ecc9c26fdc7a4f60078faaa7ca042d3e15642465ab0f39e3feba80ac0914f2039024cb793318bd0a551
|
7
|
+
data.tar.gz: 47f43debfcc01f18887b33bcbeaa6cda34dfc63a3eed465abc848d61249080fdb74e1041c04ccfc9e37b3c4d4cc1482db215d88d58ab95423698d3d5b35814e4
|
data/.rubocop.yml
CHANGED
@@ -32,6 +32,7 @@ Metrics/AbcSize:
|
|
32
32
|
Metrics/BlockLength:
|
33
33
|
Exclude:
|
34
34
|
- 'spec/**/*.rb'
|
35
|
+
- 'influxdb-rails.gemspec'
|
35
36
|
|
36
37
|
Metrics/LineLength:
|
37
38
|
Max: 100
|
@@ -51,6 +52,10 @@ Naming/UncommunicativeMethodParamName:
|
|
51
52
|
Naming/FileName:
|
52
53
|
Exclude:
|
53
54
|
- lib/influxdb-rails.rb
|
55
|
+
- sample-dashboard/Rakefile
|
56
|
+
|
57
|
+
Style/Documentation:
|
58
|
+
Enabled: false
|
54
59
|
|
55
60
|
Style/FormatStringToken:
|
56
61
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
For the full commit log, [see here](https://github.com/influxdata/influxdb-rails/commits/master).
|
4
4
|
|
5
|
+
## v1.0.0.beta4, unreleased
|
6
|
+
|
7
|
+
- Introduces a Sample Grafana Dashboard + docker-compose demo (#75/#79, @hennevogel)
|
8
|
+
- Redesign Measurement Output (#66, @dmke, @ChrisBr, @hennevogel)
|
9
|
+
- Switching from emitting eight different measurements to one called `rails`
|
10
|
+
to support easier aggregation across data, to simplify configuration and to
|
11
|
+
stay closer to the InfluxDB/Grafana nomenclature.
|
12
|
+
- Introduced configuration option `ignored_hooks` to disable specifc hooks
|
13
|
+
- Enable SQL subscriber by default
|
14
|
+
- Set a default location (:raw) for SQL subscriber
|
15
|
+
- Add dynamic values (#65, @ChrisBr)
|
16
|
+
- Remove empty tags (#64, @ChrisBr)
|
5
17
|
|
6
18
|
## v1.0.0.beta3, released 2019-01-07
|
7
19
|
|
@@ -10,7 +22,6 @@ For the full commit log, [see here](https://github.com/influxdata/influxdb-rails
|
|
10
22
|
some tags to values (#63, @ChrisBr)
|
11
23
|
- Remove SCHEMA queries from SQL instrumentation (#61, @ChrisBr)
|
12
24
|
|
13
|
-
|
14
25
|
## v1.0.0.beta2, released 2018-12-07
|
15
26
|
|
16
27
|
- Added `tags_middleware` config option (#47, @Kukunin)
|
@@ -31,15 +42,6 @@ For the full commit log, [see here](https://github.com/influxdata/influxdb-rails
|
|
31
42
|
|
32
43
|
- Support for Ruby <= 2.2.x has been removed
|
33
44
|
- Support for Rails <= 4.1.x has been removed
|
34
|
-
- Changed keys for exceptions (#43, @vassilevsky & @kkentzo)
|
35
|
-
- Exception message and backtrace are now InfluxDB values (changed from tags).
|
36
|
-
- The keys changed from `message` to `exception_message` and from
|
37
|
-
`backtrace` to `exception_backtrace`, since a single shard does not
|
38
|
-
allow for tags and values to share the same key
|
39
|
-
- To convert existing exception traces into the new format for
|
40
|
-
consistency, see [this gist][migrate].
|
41
|
-
- Removed `time` key from InfluxDB::Rails::ExceptionPresenter#context`
|
42
|
-
- use `InfluxDB::Rails.current_timestamp` directly
|
43
45
|
- Removed previously deprecated methods:
|
44
46
|
- `InfluxDB::Rails::Configuration#reraise_global_exceptions`
|
45
47
|
- `InfluxDB::Rails::Configuration#database_name`
|
data/README.md
CHANGED
@@ -13,100 +13,142 @@ metrics directly into [InfluxDB](http://influxdb.org/).
|
|
13
13
|
|
14
14
|
This gem is designed for Rails 4.2+, Ruby 2.3+ and InfluxDB 0.9+.
|
15
15
|
|
16
|
+
## Table of contents
|
17
|
+
|
18
|
+
- [Installation](#installation)
|
19
|
+
- [Usage](#installation)
|
20
|
+
- [Configuration](#configuration)
|
21
|
+
- [Demo](#demo)
|
22
|
+
- [FAQ](#frequently-asked-questions)
|
23
|
+
- [Contributing](#contributing)
|
16
24
|
|
17
25
|
## Installation
|
18
26
|
|
19
|
-
|
20
|
-
|
27
|
+
Add the gem to your `Gemfile`:
|
28
|
+
|
29
|
+
```console
|
30
|
+
echo 'gem "influxdb-rails"' >>Gemfile
|
31
|
+
bundle install
|
21
32
|
```
|
22
33
|
|
23
|
-
|
34
|
+
To get things set up, create an initializer:
|
24
35
|
|
36
|
+
```console
|
37
|
+
bundle exec rails generate influxdb
|
38
|
+
```
|
39
|
+
|
40
|
+
This creates a file `config/initializers/influxdb_rails.rb`, which allows
|
41
|
+
configuration of this gem.
|
25
42
|
|
26
43
|
## Usage
|
27
44
|
|
28
|
-
|
45
|
+
Out of the box, you'll automatically get reporting for sql, model, view and
|
46
|
+
controller Rails instrumentation for every request.
|
29
47
|
|
30
|
-
|
31
|
-
|
32
|
-
|
48
|
+
### Action Controller
|
49
|
+
|
50
|
+
Reported ActiveSupport instrumentation hooks:
|
51
|
+
|
52
|
+
- [start\_processing.action\_controller](https://guides.rubyonrails.org/active_support_instrumentation.html#start-processing-action-controller)
|
53
|
+
- [process\_action.action\_controller](https://guides.rubyonrails.org/active_support_instrumentation.html#process-action-action-controller)
|
54
|
+
|
55
|
+
Reported values:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
controller: 48.467,
|
59
|
+
view: 46.848
|
60
|
+
db: 0.157,
|
61
|
+
started: 1465839830100400200
|
62
|
+
request_id: "d5bf620b-3494-425b-b7e1-4953597ea744"
|
33
63
|
```
|
34
64
|
|
35
|
-
|
36
|
-
config should look something like this:
|
65
|
+
Reported tags:
|
37
66
|
|
38
|
-
```
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
# config.open_timeout = 5
|
49
|
-
# config.read_timeout = 30
|
50
|
-
# config.max_delay = 300
|
51
|
-
# config.time_precision = 'ms'
|
52
|
-
|
53
|
-
# config.tags_middleware = ->(tags) { tags }
|
54
|
-
|
55
|
-
# config.series_name_for_controller_runtimes = "rails.controller"
|
56
|
-
# config.series_name_for_view_runtimes = "rails.view"
|
57
|
-
# config.series_name_for_db_runtimes = "rails.db"
|
58
|
-
# config.series_name_for_render_template = "rails.render_template"
|
59
|
-
# config.series_name_for_render_partial = "rails.render_partial"
|
60
|
-
# config.series_name_for_render_collection = "rails.render_collection"
|
61
|
-
# config.series_name_for_sql = nil
|
62
|
-
# config.series_name_for_exceptions = "rails.exceptions"
|
63
|
-
# config.series_name_for_instrumentation = "instrumentation"
|
64
|
-
|
65
|
-
# Set the application name to something meaningful, by default we
|
66
|
-
# infer the app name from the Rails.application class name.
|
67
|
-
# config.application_name = Rails.application.class.parent_name
|
68
|
-
end
|
67
|
+
```ruby
|
68
|
+
{
|
69
|
+
hook: "process_action",
|
70
|
+
server: Socket.gethostname,
|
71
|
+
app_name: configuration.application_name,
|
72
|
+
method: "PostsController#index",
|
73
|
+
http_method: "GET",
|
74
|
+
format: "html",
|
75
|
+
status: "200"
|
76
|
+
}
|
69
77
|
```
|
70
78
|
|
71
|
-
|
72
|
-
|
79
|
+
### Action View
|
80
|
+
|
81
|
+
Reported ActiveSupport instrumentation hooks:
|
73
82
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
and currently requires String parsing which might cause performance issues on query
|
78
|
-
intensive applications. You can enable it by setting the `series_name_for_sql`
|
79
|
-
configuration.
|
83
|
+
- [render\_template.action\_view](https://guides.rubyonrails.org/active_support_instrumentation.html#render-template-action-view)
|
84
|
+
- [render\_partial.action\_view](https://guides.rubyonrails.org/active_support_instrumentation.html#render-partial-action-view)
|
85
|
+
- [render\_collection.action\_view](https://guides.rubyonrails.org/active_support_instrumentation.html#render-collection-action-view)
|
80
86
|
|
81
|
-
|
87
|
+
Reported values:
|
82
88
|
|
83
89
|
```ruby
|
84
|
-
|
85
|
-
|
86
|
-
|
90
|
+
value: 48.467,
|
91
|
+
count: 3,
|
92
|
+
cache_hits: 0,
|
93
|
+
request_id: "d5bf620b-3494-425b-b7e1-4953597ea744"
|
87
94
|
```
|
88
95
|
|
89
|
-
|
90
|
-
If you do that, it might be usefull to add the current context to these custom data points which can get
|
91
|
-
accessed with ``InfluxDB::Rails.current.location``.
|
96
|
+
Reported tags:
|
92
97
|
|
98
|
+
```ruby
|
99
|
+
hook: ["render_template", "render_partial", "render_collection"]
|
100
|
+
server: Socket.gethostname,
|
101
|
+
app_name: configuration.application_name,
|
102
|
+
location: "PostsController#index",
|
103
|
+
filename: "/some/file/action.html",
|
104
|
+
```
|
93
105
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
106
|
+
### Active Record
|
107
|
+
|
108
|
+
Reported ActiveSupport instrumentation hooks:
|
109
|
+
|
110
|
+
- [sql.active\_record](https://guides.rubyonrails.org/active_support_instrumentation.html#sql-active-record)
|
111
|
+
|
112
|
+
Reported values:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
sql: "SELECT \"posts\".* FROM \"posts\"",
|
116
|
+
request_id: "d5bf620b-3494-425b-b7e1-4953597ea744"
|
98
117
|
```
|
99
118
|
|
100
|
-
|
101
|
-
[influxdb-ruby](http://github.com/influxdata/influxdb-ruby) repo.
|
119
|
+
Reported tags:
|
102
120
|
|
121
|
+
```ruby
|
122
|
+
hook: "sql",
|
123
|
+
server: Socket.gethostname,
|
124
|
+
app_name: configuration.application_name,
|
125
|
+
location: "PostsController#index",
|
126
|
+
operation: "SELECT",
|
127
|
+
class_name: "POST",
|
128
|
+
name: "Post Load"
|
129
|
+
```
|
130
|
+
|
131
|
+
## Configuration
|
132
|
+
|
133
|
+
The only setting you actually need to configure is the name of the database
|
134
|
+
within the InfluxDB server instance (don't forget to create this database!).
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
InfluxDB::Rails.configure do |config|
|
138
|
+
config.client.database = "rails"
|
139
|
+
end
|
140
|
+
```
|
103
141
|
|
104
|
-
|
142
|
+
You'll find *most* of the configuration settings in the initializer file. The
|
143
|
+
canonical list of default values is located in `lib/influxdb/rails/configuration.rb`
|
144
|
+
(`InfluxDB::Rails::Configuration::DEFAULTS`).
|
145
|
+
|
146
|
+
### Custom Tags
|
105
147
|
|
106
148
|
You can modify the tags sent to InfluxDB by defining a middleware, which
|
107
|
-
receives the current tag set
|
108
|
-
|
109
|
-
|
149
|
+
receives the current tag set as argument and returns a hash in the same
|
150
|
+
form. The middleware can be any object, as long it responds to `#call`
|
151
|
+
(like a `Proc`):
|
110
152
|
|
111
153
|
```ruby
|
112
154
|
InfluxDB::Rails.configure do |config|
|
@@ -116,176 +158,159 @@ InfluxDB::Rails.configure do |config|
|
|
116
158
|
end
|
117
159
|
```
|
118
160
|
|
119
|
-
|
120
|
-
|
161
|
+
The `tags` argument is a Hash (mapping Symbol keys to String values). The
|
162
|
+
actual keys and values depend on the series name (`tags[:series]`, see
|
163
|
+
next section).
|
164
|
+
|
165
|
+
If you want to add dynamically tags or fields *per request*, you can access
|
166
|
+
`InfluxDB::Rails.current` to do so. For instance, you could add the current
|
167
|
+
user as tag or redis query time to every data point:
|
121
168
|
|
122
169
|
```ruby
|
123
170
|
class ApplicationController
|
171
|
+
before_action :set_influx_data
|
124
172
|
|
125
|
-
|
126
|
-
|
127
|
-
def set_influx_tags
|
173
|
+
def set_influx_data
|
128
174
|
InfluxDB::Rails.current.tags = { user: current_user.id }
|
175
|
+
InfluxDB::Rails.current.values = { redis_value: redis_value }
|
129
176
|
end
|
130
177
|
end
|
131
|
-
|
132
178
|
```
|
133
179
|
|
134
|
-
|
135
|
-
(`rails.controller`, `rails.view`, `rails.db` and `instrumentation`):
|
180
|
+
### Custom client configuration
|
136
181
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
app_name: configuration.application_name,
|
142
|
-
http_method: payload[:method],
|
143
|
-
format: payload[:format],
|
144
|
-
status: payload[:status]
|
145
|
-
}
|
146
|
-
```
|
147
|
-
For the render series (``rails.render_partial``, ``rails.render_view`` and ``rails.render_collection``)
|
182
|
+
The settings named `config.client.*` are used to construct an `InfluxDB::Client`
|
183
|
+
instance, which is used internally to transmit the reporting data points
|
184
|
+
to your InfluxDB server. You can access this client as well, and perform
|
185
|
+
arbitrary operations on your data:
|
148
186
|
|
149
187
|
```ruby
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
filename: payload[:identifier],
|
154
|
-
count: payload[:count],
|
155
|
-
cache_hits: payload[:cache_hits],
|
188
|
+
InfluxDB::Rails.client.write_point "events",
|
189
|
+
tags: { url: "/foo", user_id: current_user.id, location: InfluxDB::Rails.current.location },
|
190
|
+
values: { value: 0 }
|
156
191
|
```
|
157
192
|
|
158
|
-
|
159
|
-
|
160
|
-
```ruby
|
161
|
-
server: Socket.gethostname,
|
162
|
-
app_name: configuration.application_name,
|
163
|
-
location: "#{payload[:controller]}##{payload[:action]}",,
|
164
|
-
operation: "SELECT",
|
165
|
-
class_name: "USER",
|
166
|
-
name: payload[:name],
|
167
|
-
```
|
193
|
+
If you do that, it might be useful to add the current context to these custom
|
194
|
+
data points which can get accessed with `InfluxDB::Rails.current.location`.
|
168
195
|
|
169
|
-
|
196
|
+
See [influxdb-ruby](http://github.com/influxdata/influxdb-ruby) for a
|
197
|
+
full list of configuration options and detailed usage.
|
170
198
|
|
199
|
+
### Disabling hooks
|
171
200
|
|
172
|
-
|
201
|
+
If you are not interested in certain reports you can disable them in the configuration.
|
173
202
|
|
174
203
|
```ruby
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
framework: InfluxDB::Rails.configuration.framework,
|
179
|
-
framework_version: InfluxDB::Rails.configuration.framework_version,
|
180
|
-
language: "Ruby",
|
181
|
-
language_version: "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}",
|
182
|
-
custom_data: @custom_data,
|
183
|
-
class: @exception.class.to_s,
|
184
|
-
method: "#{@controller}##{@action}",
|
185
|
-
filename: File.basename(@backtrace.lines.first.try(:file)),
|
186
|
-
server: Socket.gethostname,
|
187
|
-
status: "open",
|
188
|
-
}
|
204
|
+
InfluxDB::Rails.configure do |config|
|
205
|
+
config.ignored_hooks = ['sql.active_record', 'render_template.action_view']
|
206
|
+
end
|
189
207
|
```
|
190
208
|
|
209
|
+
## Demo
|
210
|
+
Want to see this in action? Check out our [sample dashboard](https://github.com/influxdata/influxdb-rails/tree/master/sample-dashboard).
|
191
211
|
|
192
212
|
## Frequently Asked Questions
|
193
213
|
|
214
|
+
### I'm seeing far less requests recorded in InfluxDB than my logs suggest.
|
194
215
|
|
195
|
-
|
216
|
+
By default, this gem writes data points with *millisecond time precision*
|
217
|
+
to the InfluxDB server. If you have more than 1000 requests/second (and/or
|
218
|
+
multiple parallel requests), **only the last** data point (within the
|
219
|
+
same tag set) is stored. See [InfluxDB server docs][duplicate-points] for
|
220
|
+
further details.
|
196
221
|
|
197
|
-
|
198
|
-
to
|
199
|
-
|
222
|
+
To work around this limitation, set the `config.client.time_precision`
|
223
|
+
to one of `"us"` (microseconds, 1·10<sup>-6</sup>s) or `"ns"` (nanoseconds,
|
224
|
+
1·10<sup>-9</sup>s).
|
200
225
|
|
201
|
-
|
202
|
-
|
203
|
-
of `"ms"` (milliseconds, 1·10<sup>-3</sup>s), `"us"` (microseconds,
|
204
|
-
1·10<sup>-6</sup>s) or `"ns"` (nanoseconds, 1·10<sup>-9</sup>s).
|
226
|
+
Please note: This will only ever reduce the likelihood of data points
|
227
|
+
overwriting each other, but not eliminate it completely.
|
205
228
|
|
206
229
|
[duplicate-points]: https://docs.influxdata.com/influxdb/v1.4/troubleshooting/frequently-asked-questions/#how-does-influxdb-handle-duplicate-points
|
207
230
|
|
208
231
|
|
209
|
-
|
232
|
+
### How does the measurement influence the response time?
|
233
|
+
|
234
|
+
This gem subscribes to various `ActiveSupport::Notifications` hooks.
|
235
|
+
(cf. [guide][arn-guide] · [docs][arn-docs] · [impl][arn-impl]). The
|
236
|
+
controller notifications are run *after* a controller action has finished,
|
237
|
+
and should not impact the response time.
|
210
238
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
239
|
+
Other notification hooks (rendering and SQL queries) run *inline* in the
|
240
|
+
request processing. The amount of overhead introduced should be negligible,
|
241
|
+
though. However reporting of SQL queries relies on Ruby string parsing which
|
242
|
+
might cause performance issues on traffic intensive applications. Disable it in
|
243
|
+
the configuration if you are not willing to tolerate this.
|
215
244
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
thread, which batches multiple data points.
|
245
|
+
By default, this gem performs writes to InfluxDB asynchronously. A single
|
246
|
+
hooks usually only performs some time delta calculations, and then enqueues
|
247
|
+
the data point into a worker queue (which is processed by a background
|
248
|
+
thread).
|
221
249
|
|
222
|
-
If you, however, use a synchronous client (`config.async = false`),
|
223
|
-
data points are immediately sent to the InfluxDB server. Depending on
|
250
|
+
If you, however, use a synchronous client (`config.client.async = false`),
|
251
|
+
the data points are immediately sent to the InfluxDB server. Depending on
|
224
252
|
the network link, this might cause the HTTP thread to block a lot longer.
|
225
253
|
|
226
254
|
[arn-guide]: http://guides.rubyonrails.org/v5.1/active_support_instrumentation.html#process-action-action-controller
|
227
255
|
[arn-docs]: http://api.rubyonrails.org/v5.1/classes/ActiveSupport/Notifications.html
|
228
256
|
[arn-impl]: https://github.com/rails/rails/blob/5-1-stable/actionpack/lib/action_controller/metal/instrumentation.rb#L30-L38
|
229
257
|
|
258
|
+
### How does this gem handle an unreachable InfluxDB server?
|
230
259
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
succeedes (see [client docs][] for details). This has two important
|
235
|
-
implcations, depending on the value of `config.async`:
|
260
|
+
By default, the InfluxDB client will retry indefinitely, until a write
|
261
|
+
succeeds (see [client docs][] for details). This has two important
|
262
|
+
implications, depending on the value of `config.client.async`:
|
236
263
|
|
237
|
-
- if the client runs asynchronously (i.e. in a
|
238
|
-
might fill up with
|
264
|
+
- if the client runs asynchronously (i.e. in a separate thread), the queue
|
265
|
+
might fill up with hundreds of megabytes of data points
|
239
266
|
- if the client runs synchronously (i.e. inline in the request/response
|
240
267
|
cycle), it might block all available request threads
|
241
268
|
|
242
|
-
In both cases, your application server might become
|
243
|
-
to be restarted (which can happen automatically in `cgroups` contexts
|
269
|
+
In both cases, your application server might become unresponsive and needs
|
270
|
+
to be restarted (which can happen automatically in `cgroups` contexts,
|
271
|
+
like Docker containers).
|
244
272
|
|
245
|
-
If you setup a maximum retry value (`Integer === config.retry`),
|
246
|
-
client will try
|
273
|
+
If you setup a maximum retry value (`Integer === config.client.retry`),
|
274
|
+
the client will try up to that amount of times to send the data to the server
|
247
275
|
and (on final error) log an error and discard the values.
|
248
276
|
|
249
277
|
[client docs]: https://github.com/influxdata/influxdb-ruby#retry
|
250
278
|
|
251
|
-
|
252
|
-
**Q: What happens with unwritten points, when the application restarts?**
|
253
|
-
|
254
|
-
The data points are simply discarded.
|
255
|
-
|
256
|
-
|
257
|
-
**Q: What happens, when the InfluxDB client or this gem throws an exception? Will the user see 500 errors?**
|
279
|
+
### What happens, when the InfluxDB client or this gem throws an exception? Will the user see 500 errors?
|
258
280
|
|
259
281
|
No. The controller instrumentation is wrapped in a `rescue StandardError`
|
260
282
|
clause, i.e. this gem will only write the error to the `client.logger`
|
261
283
|
(`Rails.logger` by default) and not disturb the user experience.
|
262
284
|
|
285
|
+
### What happens with unwritten points, when the application restarts?
|
263
286
|
|
264
|
-
|
265
|
-
|
266
|
-
```
|
267
|
-
git clone git@github.com:influxdata/influxdb-rails.git
|
268
|
-
cd influxdb-rails
|
269
|
-
bundle
|
270
|
-
bundle exec rake
|
271
|
-
```
|
272
|
-
|
287
|
+
The data points are simply discarded.
|
273
288
|
|
274
289
|
## Contributing
|
275
290
|
|
276
|
-
- Fork this repository on GitHub
|
277
|
-
- Make your changes
|
291
|
+
- Fork this repository on GitHub
|
292
|
+
- Make your changes
|
278
293
|
- Add tests.
|
279
294
|
- Add an entry in the `CHANGELOG.md` in the "unreleased" section on top.
|
280
295
|
- Run the tests:
|
281
296
|
- Either run them manually:
|
297
|
+
|
282
298
|
```console
|
283
|
-
|
299
|
+
rake test:all
|
284
300
|
```
|
301
|
+
|
285
302
|
- or wait for [Travis][travis-pr] to pick up your changes, *after*
|
286
303
|
you made a pull request.
|
287
304
|
- Send a pull request.
|
288
|
-
|
289
|
-
- If your changes look good, we'll merge them.
|
305
|
+
- If your changes are looking good, we'll merge them.
|
290
306
|
|
291
307
|
[travis-pr]: https://travis-ci.org/influxdata/influxdb-rails/pull_requests
|
308
|
+
|
309
|
+
### Testing Tasks
|
310
|
+
|
311
|
+
```console
|
312
|
+
rake # unit tests + Rubocop linting
|
313
|
+
rake spec # only unit tests
|
314
|
+
rake rubocop # only Rubocop linter
|
315
|
+
rake test:all # integration tests with various Rails version
|
316
|
+
```
|
data/influxdb-rails.gemspec
CHANGED
@@ -4,14 +4,19 @@ require "influxdb/rails/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "influxdb-rails"
|
7
|
-
spec.version = InfluxDB::Rails::VERSION
|
8
|
-
spec.authors = ["Dominik Menke", "Todd Persen"]
|
9
|
-
spec.email = ["dominik.menke@gmail.com", "todd@influxdb.com"]
|
10
|
-
spec.homepage = "https://influxdata.com"
|
11
7
|
spec.summary = "InfluxDB bindings for Ruby on Rails."
|
12
|
-
spec.description = "This gem
|
13
|
-
|
8
|
+
spec.description = "This gem instruments your Ruby on Rails application using InfluxDB."
|
9
|
+
spec.version = InfluxDB::Rails::VERSION
|
10
|
+
spec.authors = ["Christian Bruckmayer", "Henne Vogelsang"]
|
11
|
+
spec.email = ["christian@bruckmayer.net", "hvogel@hennevogel.de"]
|
14
12
|
spec.licenses = ["MIT"]
|
13
|
+
spec.homepage = "https://influxdata.com"
|
14
|
+
spec.metadata = {
|
15
|
+
"bug_tracker_uri" => "https://github.com/influxdata/influxdb-rails/issues",
|
16
|
+
"changelog_uri" => "https://github.com/influxdata/influxdb-rails/blob/master/CHANGELOG.md",
|
17
|
+
"documentation_uri" => "https://github.com/influxdata/influxdb-rails/blob/master/README.md",
|
18
|
+
"source_code_uri" => "https://github.com/influxdata/influxdb-rails",
|
19
|
+
}
|
15
20
|
|
16
21
|
spec.files = `git ls-files`.split($/) # rubocop:disable Style/SpecialGlobalVars
|
17
22
|
spec.test_files = spec.files.grep(%r{^(test|spec|features|smoke)/})
|
@@ -25,11 +30,12 @@ Gem::Specification.new do |spec|
|
|
25
30
|
spec.add_development_dependency "activerecord"
|
26
31
|
spec.add_development_dependency "bundler", ">= 1.0.0"
|
27
32
|
spec.add_development_dependency "fakeweb"
|
33
|
+
spec.add_development_dependency "pry"
|
28
34
|
spec.add_development_dependency "rake"
|
29
35
|
spec.add_development_dependency "rdoc"
|
30
36
|
spec.add_development_dependency "rspec"
|
31
37
|
spec.add_development_dependency "rspec-rails", ">= 3.0.0"
|
32
38
|
spec.add_development_dependency "rubocop", "~> 0.61.1"
|
33
|
-
spec.add_development_dependency "sqlite3"
|
39
|
+
spec.add_development_dependency "sqlite3", "1.3.13"
|
34
40
|
spec.add_development_dependency "tzinfo"
|
35
41
|
end
|