influxdb-rails 1.0.1.beta1 → 1.0.1.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -6
- data/CHANGELOG.md +6 -0
- data/README.md +47 -0
- data/influxdb-rails.gemspec +1 -0
- data/lib/influxdb-rails.rb +1 -0
- data/lib/influxdb/rails/middleware/action_mailer_subscriber.rb +22 -0
- data/lib/influxdb/rails/railtie.rb +1 -0
- data/lib/influxdb/rails/version.rb +1 -1
- data/spec/requests/action_mailer_deliver_metrics_spec.rb +49 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/rails5/app.rb +14 -0
- data/spec/support/rails6/app.rb +14 -0
- data/spec/support/views/layouts/mailer.txt.erb +1 -0
- metadata +25 -8
- data/gemfiles/Gemfile.rails-5.0.x +0 -9
- data/gemfiles/Gemfile.rails-5.1.x +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d47f714f971f95efc094148a585d056fe54cfa5847d30a2e18847ccc87a63f7b
|
4
|
+
data.tar.gz: 16c57b616923500e54755db3116560f7573837cc2c6c663ff1ecaf03b30bc16e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 957abc17d22ddb564455fa17c3dbb927715dbf44b004bc53da1c71dc405d3d15ca0b9fa7804c7bd0d30e09f68d68bc7b82dcffea9e4c1dd8d07086065d0f6e8f
|
7
|
+
data.tar.gz: 6a8f535427d62b5b7db4830885a26fb8c4ed64ffce7d8b40d2cae618d130829bb6ee5cffcaad34a1443233e4fec5eca154638511b9adf1d96fb61b91c51dda33
|
data/.travis.yml
CHANGED
@@ -10,12 +10,9 @@ rvm:
|
|
10
10
|
- "2.7"
|
11
11
|
- "2.6"
|
12
12
|
- "2.5"
|
13
|
-
- "2.4"
|
14
13
|
gemfile:
|
15
14
|
- gemfiles/Gemfile.rails-6.0.x
|
16
15
|
- gemfiles/Gemfile.rails-5.2.x
|
17
|
-
- gemfiles/Gemfile.rails-5.1.x
|
18
|
-
- gemfiles/Gemfile.rails-5.0.x
|
19
16
|
env:
|
20
17
|
- TEST_TASK=spec
|
21
18
|
matrix:
|
@@ -23,9 +20,6 @@ matrix:
|
|
23
20
|
- rvm: ruby-head
|
24
21
|
include:
|
25
22
|
- { rvm: "2.6", gemfile: "Gemfile", env: [TEST_TASK=rubocop] }
|
26
|
-
exclude:
|
27
|
-
# Rails > 5 not on MRI 2.4+
|
28
|
-
- { rvm: "2.4", gemfile: "gemfiles/Gemfile.rails-6.0.x" }
|
29
23
|
addons:
|
30
24
|
apt:
|
31
25
|
packages:
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
For the full commit log, [see here](https://github.com/influxdata/influxdb-rails/commits/master).
|
4
4
|
|
5
|
+
## v1.0.1.beta2, released 2020-09-14
|
6
|
+
- Implement [`deliver.action_mailer`](https://guides.rubyonrails.org/active_support_instrumentation.html#deliver-action-mailer) subscriber
|
7
|
+
- Add missing Active Job documentation
|
8
|
+
- Drop support for Ruby 2.4
|
9
|
+
- Drop support for Rails < 5.2
|
10
|
+
|
5
11
|
## v1.0.1.beta1, released 2020-08-21
|
6
12
|
- Drop support for Ruby 2.3
|
7
13
|
- Drop support for Rails 4.x
|
data/README.md
CHANGED
@@ -132,6 +132,53 @@ Reported tags:
|
|
132
132
|
name: "Post Load"
|
133
133
|
```
|
134
134
|
|
135
|
+
### Active Job
|
136
|
+
|
137
|
+
Reported ActiveSupport instrumentation hooks:
|
138
|
+
|
139
|
+
- [enqueue.active\_job](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-active-job)
|
140
|
+
- [perform_start.active\_job](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-start-active-job)
|
141
|
+
- [perform.active\_job](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-active-job)
|
142
|
+
|
143
|
+
Reported values:
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
value: 89.467
|
147
|
+
```
|
148
|
+
|
149
|
+
Reported tags:
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
hook: ["enqueue", "perform_start", "perform"],
|
153
|
+
state: ["queued", "running", "succeeded", "failed"],
|
154
|
+
job: "SomeJobClassName",
|
155
|
+
queue: "queue_name"
|
156
|
+
```
|
157
|
+
|
158
|
+
*Note*: Only the measurements with the hook `perform` report a duration in the value.
|
159
|
+
The other hooks are counters and always report a value of `1`.
|
160
|
+
|
161
|
+
### Action Mailer
|
162
|
+
|
163
|
+
Reported ActiveSupport instrumentation hooks:
|
164
|
+
|
165
|
+
- [deliver.action\_mailer](https://guides.rubyonrails.org/active_support_instrumentation.html#deliver-action-mailer)
|
166
|
+
|
167
|
+
Reported values:
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
value: 1
|
171
|
+
```
|
172
|
+
|
173
|
+
Reported tags:
|
174
|
+
|
175
|
+
```ruby
|
176
|
+
hook: "deliver",
|
177
|
+
mailer: "SomeMailerClassName"
|
178
|
+
```
|
179
|
+
|
180
|
+
*Note*: The hook is just a counter and always report a value of `1`.
|
181
|
+
|
135
182
|
## Configuration
|
136
183
|
|
137
184
|
The only setting you actually need to configure is the name of the database
|
data/influxdb-rails.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_runtime_dependency "influxdb", "~> 0.6", ">= 0.6.4"
|
28
28
|
spec.add_runtime_dependency "railties", ">= 5.0"
|
29
29
|
|
30
|
+
spec.add_development_dependency "actionmailer"
|
30
31
|
spec.add_development_dependency "activejob"
|
31
32
|
spec.add_development_dependency "activerecord"
|
32
33
|
spec.add_development_dependency "bundler", ">= 1.0.0"
|
data/lib/influxdb-rails.rb
CHANGED
@@ -8,6 +8,7 @@ require "influxdb/rails/middleware/request_subscriber"
|
|
8
8
|
require "influxdb/rails/middleware/sql_subscriber"
|
9
9
|
require "influxdb/rails/middleware/active_record_subscriber"
|
10
10
|
require "influxdb/rails/middleware/active_job_subscriber"
|
11
|
+
require "influxdb/rails/middleware/action_mailer_subscriber"
|
11
12
|
require "influxdb/rails/sql/query"
|
12
13
|
require "influxdb/rails/version"
|
13
14
|
require "influxdb/rails/configuration"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "influxdb/rails/middleware/subscriber"
|
2
|
+
|
3
|
+
module InfluxDB
|
4
|
+
module Rails
|
5
|
+
module Middleware
|
6
|
+
class ActionMailerSubscriber < Subscriber # :nodoc:
|
7
|
+
private
|
8
|
+
|
9
|
+
def values
|
10
|
+
{ value: 1 }
|
11
|
+
end
|
12
|
+
|
13
|
+
def tags
|
14
|
+
{
|
15
|
+
hook: "deliver",
|
16
|
+
mailer: payload[:mailer],
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -34,6 +34,7 @@ module InfluxDB
|
|
34
34
|
"enqueue.active_job" => Middleware::ActiveJobSubscriber,
|
35
35
|
"perform_start.active_job" => Middleware::ActiveJobSubscriber,
|
36
36
|
"perform.active_job" => Middleware::ActiveJobSubscriber,
|
37
|
+
"deliver.action_mailer" => Middleware::ActionMailerSubscriber,
|
37
38
|
"block_instrumentation.influxdb_rails" => Middleware::BlockInstrumentationSubscriber,
|
38
39
|
}.each do |hook_name, subscriber|
|
39
40
|
ActiveSupport::Notifications.subscribe(hook_name, subscriber)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "ActionMailer deliver metrics", type: :request do
|
4
|
+
let(:tags_middleware) do
|
5
|
+
lambda do |tags|
|
6
|
+
tags.merge(tags_middleware: :tags_middleware)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
before do
|
10
|
+
allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:ignored_environments).and_return(%w[development])
|
11
|
+
allow_any_instance_of(ActionDispatch::Request).to receive(:request_id).and_return(:request_id)
|
12
|
+
allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:application_name).and_return(:app_name)
|
13
|
+
allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:tags_middleware).and_return(tags_middleware)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "writes metric" do
|
17
|
+
get "/metrics"
|
18
|
+
|
19
|
+
expect_metric(
|
20
|
+
tags: a_hash_including(
|
21
|
+
hook: "deliver",
|
22
|
+
mailer: "MetricMailer",
|
23
|
+
location: "MetricsController#index",
|
24
|
+
additional_tag: :value,
|
25
|
+
server: Socket.gethostname,
|
26
|
+
app_name: :app_name,
|
27
|
+
tags_middleware: :tags_middleware
|
28
|
+
),
|
29
|
+
values: a_hash_including(
|
30
|
+
additional_value: :value,
|
31
|
+
request_id: :request_id,
|
32
|
+
value: 1
|
33
|
+
)
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "does not write metric when hook is ignored" do
|
38
|
+
allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:ignored_hooks).and_return(["deliver.action_mailer"])
|
39
|
+
|
40
|
+
get "/metrics"
|
41
|
+
|
42
|
+
expect_no_metric(
|
43
|
+
tags: a_hash_including(
|
44
|
+
hook: "deliver",
|
45
|
+
mailer: "MetricMailer"
|
46
|
+
)
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/rails5/app.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "action_controller/railtie"
|
2
2
|
require "active_record/railtie"
|
3
3
|
require "active_job"
|
4
|
+
require "action_mailer"
|
4
5
|
|
5
6
|
app = Class.new(Rails::Application)
|
6
7
|
app.config.secret_key_base = "1234567890abcdef1234567890abcdef"
|
@@ -11,6 +12,7 @@ app.config.eager_load = false
|
|
11
12
|
app.config.root = __dir__
|
12
13
|
Rails.backtrace_cleaner.remove_silencers!
|
13
14
|
ActiveJob::Base.logger = Rails.logger
|
15
|
+
ActionMailer::Base.delivery_method = :test
|
14
16
|
app.initialize!
|
15
17
|
|
16
18
|
app.routes.draw do
|
@@ -38,6 +40,17 @@ class MetricJob < ActiveJob::Base
|
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
43
|
+
class MetricMailer < ActionMailer::Base
|
44
|
+
default from: "from@example.com"
|
45
|
+
layout "mailer"
|
46
|
+
|
47
|
+
def welcome_mail
|
48
|
+
mail(to: "eisendieter@werder.de", subject: "Welcome to metrics!") do |format|
|
49
|
+
format.text { render plain: "Hello Dieter!" }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
41
54
|
class Metric < ActiveRecord::Base; end
|
42
55
|
class ApplicationController < ActionController::Base; end
|
43
56
|
class MetricsController < ApplicationController
|
@@ -53,6 +66,7 @@ class MetricsController < ApplicationController
|
|
53
66
|
1 + 1
|
54
67
|
end
|
55
68
|
MetricJob.perform_later
|
69
|
+
MetricMailer.with(user: "eisendieter").welcome_mail.deliver_now
|
56
70
|
Metric.create!(name: "name")
|
57
71
|
end
|
58
72
|
|
data/spec/support/rails6/app.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "action_controller/railtie"
|
2
2
|
require "active_record/railtie"
|
3
3
|
require "active_job"
|
4
|
+
require "action_mailer"
|
4
5
|
|
5
6
|
app = Class.new(Rails::Application)
|
6
7
|
app.config.secret_key_base = "1234567890abcdef1234567890abcdef"
|
@@ -11,6 +12,7 @@ app.config.eager_load = false
|
|
11
12
|
app.config.root = __dir__
|
12
13
|
Rails.backtrace_cleaner.remove_silencers!
|
13
14
|
ActiveJob::Base.logger = Rails.logger
|
15
|
+
ActionMailer::Base.delivery_method = :test
|
14
16
|
app.initialize!
|
15
17
|
|
16
18
|
app.routes.draw do
|
@@ -38,6 +40,17 @@ class MetricJob < ActiveJob::Base
|
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
43
|
+
class MetricMailer < ActionMailer::Base
|
44
|
+
default from: "from@example.com"
|
45
|
+
layout "mailer"
|
46
|
+
|
47
|
+
def welcome_mail
|
48
|
+
mail(to: "eisendieter@werder.de", subject: "Welcome to metrics!") do |format|
|
49
|
+
format.text { render plain: "Hello Dieter!" }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
41
54
|
class Metric < ActiveRecord::Base; end
|
42
55
|
class ApplicationController < ActionController::Base; end
|
43
56
|
class MetricsController < ApplicationController
|
@@ -53,6 +66,7 @@ class MetricsController < ApplicationController
|
|
53
66
|
1 + 1
|
54
67
|
end
|
55
68
|
MetricJob.perform_later
|
69
|
+
MetricMailer.with(user: "eisendieter").welcome_mail.deliver_now
|
56
70
|
Metric.create!(name: "name")
|
57
71
|
end
|
58
72
|
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: influxdb-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.1.
|
4
|
+
version: 1.0.1.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Bruckmayer
|
8
8
|
- Henne Vogelsang
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: influxdb
|
@@ -45,6 +45,20 @@ dependencies:
|
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '5.0'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: actionmailer
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
48
62
|
- !ruby/object:Gem::Dependency
|
49
63
|
name: activejob
|
50
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -246,8 +260,6 @@ files:
|
|
246
260
|
- README.md
|
247
261
|
- Rakefile
|
248
262
|
- config.ru
|
249
|
-
- gemfiles/Gemfile.rails-5.0.x
|
250
|
-
- gemfiles/Gemfile.rails-5.1.x
|
251
263
|
- gemfiles/Gemfile.rails-5.2.x
|
252
264
|
- gemfiles/Gemfile.rails-6.0.x
|
253
265
|
- influxdb-rails.gemspec
|
@@ -256,6 +268,7 @@ files:
|
|
256
268
|
- lib/influxdb/rails/context.rb
|
257
269
|
- lib/influxdb/rails/helpers/rspec_matchers.rb
|
258
270
|
- lib/influxdb/rails/metric.rb
|
271
|
+
- lib/influxdb/rails/middleware/action_mailer_subscriber.rb
|
259
272
|
- lib/influxdb/rails/middleware/active_job_subscriber.rb
|
260
273
|
- lib/influxdb/rails/middleware/active_record_subscriber.rb
|
261
274
|
- lib/influxdb/rails/middleware/block_instrumentation_subscriber.rb
|
@@ -285,6 +298,7 @@ files:
|
|
285
298
|
- sample-dashboard/provisioning/performance-request.json
|
286
299
|
- sample-dashboard/provisioning/performance.json
|
287
300
|
- spec/requests/action_controller_metrics_spec.rb
|
301
|
+
- spec/requests/action_mailer_deliver_metrics_spec.rb
|
288
302
|
- spec/requests/action_view_collection_metrics_spec.rb
|
289
303
|
- spec/requests/action_view_partial_metrics_spec.rb
|
290
304
|
- spec/requests/action_view_template_metrics_spec.rb
|
@@ -300,6 +314,7 @@ files:
|
|
300
314
|
- spec/support/broken_client.rb
|
301
315
|
- spec/support/rails5/app.rb
|
302
316
|
- spec/support/rails6/app.rb
|
317
|
+
- spec/support/views/layouts/mailer.txt.erb
|
303
318
|
- spec/support/views/metrics/_item.html.erb
|
304
319
|
- spec/support/views/metrics/index.html.erb
|
305
320
|
- spec/support/views/metrics/show.html.erb
|
@@ -315,7 +330,7 @@ metadata:
|
|
315
330
|
changelog_uri: https://github.com/influxdata/influxdb-rails/blob/master/CHANGELOG.md
|
316
331
|
documentation_uri: https://github.com/influxdata/influxdb-rails/blob/master/README.md
|
317
332
|
source_code_uri: https://github.com/influxdata/influxdb-rails
|
318
|
-
post_install_message:
|
333
|
+
post_install_message:
|
319
334
|
rdoc_options: []
|
320
335
|
require_paths:
|
321
336
|
- lib
|
@@ -330,13 +345,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
330
345
|
- !ruby/object:Gem::Version
|
331
346
|
version: 1.3.1
|
332
347
|
requirements: []
|
333
|
-
rubyforge_project:
|
348
|
+
rubyforge_project:
|
334
349
|
rubygems_version: 2.7.6.2
|
335
|
-
signing_key:
|
350
|
+
signing_key:
|
336
351
|
specification_version: 4
|
337
352
|
summary: InfluxDB bindings for Ruby on Rails.
|
338
353
|
test_files:
|
339
354
|
- spec/requests/action_controller_metrics_spec.rb
|
355
|
+
- spec/requests/action_mailer_deliver_metrics_spec.rb
|
340
356
|
- spec/requests/action_view_collection_metrics_spec.rb
|
341
357
|
- spec/requests/action_view_partial_metrics_spec.rb
|
342
358
|
- spec/requests/action_view_template_metrics_spec.rb
|
@@ -352,6 +368,7 @@ test_files:
|
|
352
368
|
- spec/support/broken_client.rb
|
353
369
|
- spec/support/rails5/app.rb
|
354
370
|
- spec/support/rails6/app.rb
|
371
|
+
- spec/support/views/layouts/mailer.txt.erb
|
355
372
|
- spec/support/views/metrics/_item.html.erb
|
356
373
|
- spec/support/views/metrics/index.html.erb
|
357
374
|
- spec/support/views/metrics/show.html.erb
|