influxdb-rails 1.0.1.beta2 → 1.0.3
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/.github/workflows/rubocop.yml +18 -0
- data/.github/workflows/spec.yml +32 -0
- data/.rubocop.yml +36 -7
- data/CHANGELOG.md +22 -1
- data/README.md +43 -34
- data/gemfiles/Gemfile.rails-6.0.x +1 -2
- data/gemfiles/Gemfile.rails-6.1.x +9 -0
- data/influxdb-rails.gemspec +2 -2
- data/lib/influxdb/rails/middleware/active_job_subscriber.rb +11 -11
- data/lib/influxdb/rails/middleware/request_subscriber.rb +9 -1
- data/lib/influxdb/rails/railtie.rb +0 -1
- data/lib/influxdb/rails/sql/normalizer.rb +3 -3
- data/lib/influxdb/rails/tags.rb +2 -2
- data/lib/influxdb/rails/values.rb +1 -1
- data/lib/influxdb/rails/version.rb +1 -1
- data/lib/influxdb-rails.rb +1 -2
- 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 +24 -10
- data/spec/requests/action_mailer_deliver_metrics_spec.rb +4 -11
- data/spec/requests/action_view_collection_metrics_spec.rb +7 -16
- data/spec/requests/action_view_partial_metrics_spec.rb +6 -15
- data/spec/requests/action_view_template_metrics_spec.rb +6 -15
- data/spec/requests/active_job_enqueue_metrics_spec.rb +6 -15
- data/spec/requests/active_job_perform_metrics_spec.rb +5 -11
- data/spec/requests/active_record_instantiation_metrics_spec.rb +7 -16
- data/spec/requests/active_record_sql_metrics_spec.rb +13 -29
- data/spec/requests/block_inistrumentation_spec.rb +8 -17
- data/spec/requests/context_spec.rb +1 -1
- data/spec/requests/logger_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/support/rails5/app.rb +3 -4
- data/spec/support/rails6/app.rb +3 -4
- data/spec/unit/tags.rb +47 -0
- metadata +25 -14
- data/.travis.yml +0 -28
- data/spec/requests/active_job_perform_start_metrics_spec.rb +0 -68
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
1
|
+
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "ActionView partial metrics", type: :request do
|
4
4
|
let(:tags_middleware) do
|
@@ -17,18 +17,11 @@ RSpec.describe "ActionView partial metrics", type: :request do
|
|
17
17
|
|
18
18
|
expect_metric(
|
19
19
|
tags: a_hash_including(
|
20
|
-
|
21
|
-
|
22
|
-
additional_tag: :value,
|
23
|
-
filename: include("spec/support/views/metrics/_item.html.erb"),
|
24
|
-
server: Socket.gethostname,
|
25
|
-
app_name: :app_name,
|
26
|
-
tags_middleware: :tags_middleware
|
20
|
+
hook: "render_partial",
|
21
|
+
filename: include("spec/support/views/metrics/_item.html.erb")
|
27
22
|
),
|
28
23
|
values: a_hash_including(
|
29
|
-
|
30
|
-
request_id: :request_id,
|
31
|
-
value: be_between(1, 30)
|
24
|
+
value: be_between(1, 500)
|
32
25
|
)
|
33
26
|
)
|
34
27
|
end
|
@@ -40,8 +33,7 @@ RSpec.describe "ActionView partial metrics", type: :request do
|
|
40
33
|
|
41
34
|
expect_metric(
|
42
35
|
tags: a_hash_including(
|
43
|
-
|
44
|
-
hook: "render_partial"
|
36
|
+
hook: "render_partial"
|
45
37
|
),
|
46
38
|
timestamp: 1_514_797_200
|
47
39
|
)
|
@@ -54,8 +46,7 @@ RSpec.describe "ActionView partial metrics", type: :request do
|
|
54
46
|
|
55
47
|
expect_no_metric(
|
56
48
|
tags: a_hash_including(
|
57
|
-
|
58
|
-
hook: "render_partial"
|
49
|
+
hook: "render_partial"
|
59
50
|
)
|
60
51
|
)
|
61
52
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
1
|
+
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "ActionView template metrics", type: :request do
|
4
4
|
let(:tags_middleware) do
|
@@ -17,18 +17,11 @@ RSpec.describe "ActionView template metrics", type: :request do
|
|
17
17
|
|
18
18
|
expect_metric(
|
19
19
|
tags: a_hash_including(
|
20
|
-
|
21
|
-
|
22
|
-
additional_tag: :value,
|
23
|
-
filename: include("spec/support/views/metrics/index.html.erb"),
|
24
|
-
server: Socket.gethostname,
|
25
|
-
app_name: :app_name,
|
26
|
-
tags_middleware: :tags_middleware
|
20
|
+
hook: "render_template",
|
21
|
+
filename: include("spec/support/views/metrics/index.html.erb")
|
27
22
|
),
|
28
23
|
values: a_hash_including(
|
29
|
-
|
30
|
-
request_id: :request_id,
|
31
|
-
value: be_between(1, 30)
|
24
|
+
value: be_between(1, 500)
|
32
25
|
)
|
33
26
|
)
|
34
27
|
end
|
@@ -40,8 +33,7 @@ RSpec.describe "ActionView template metrics", type: :request do
|
|
40
33
|
|
41
34
|
expect_metric(
|
42
35
|
tags: a_hash_including(
|
43
|
-
|
44
|
-
hook: "render_template"
|
36
|
+
hook: "render_template"
|
45
37
|
),
|
46
38
|
timestamp: 1_514_797_200
|
47
39
|
)
|
@@ -54,8 +46,7 @@ RSpec.describe "ActionView template metrics", type: :request do
|
|
54
46
|
|
55
47
|
expect_no_metric(
|
56
48
|
tags: a_hash_including(
|
57
|
-
|
58
|
-
hook: "render_template"
|
49
|
+
hook: "render_template"
|
59
50
|
)
|
60
51
|
)
|
61
52
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
1
|
+
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "ActiveJob enqueue metrics", type: :request do
|
4
4
|
let(:tags_middleware) do
|
@@ -18,20 +18,13 @@ RSpec.describe "ActiveJob enqueue metrics", type: :request do
|
|
18
18
|
|
19
19
|
expect_metric(
|
20
20
|
tags: a_hash_including(
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
state: "queued",
|
26
|
-
additional_tag: :value,
|
27
|
-
server: Socket.gethostname,
|
28
|
-
app_name: :app_name,
|
29
|
-
tags_middleware: :tags_middleware
|
21
|
+
hook: "enqueue",
|
22
|
+
job: "MetricJob",
|
23
|
+
queue: "default",
|
24
|
+
state: "queued"
|
30
25
|
),
|
31
26
|
values: a_hash_including(
|
32
|
-
|
33
|
-
request_id: :request_id,
|
34
|
-
value: 1
|
27
|
+
value: 1
|
35
28
|
)
|
36
29
|
)
|
37
30
|
end
|
@@ -43,7 +36,6 @@ RSpec.describe "ActiveJob enqueue metrics", type: :request do
|
|
43
36
|
|
44
37
|
expect_metric(
|
45
38
|
tags: a_hash_including(
|
46
|
-
location: "MetricsController#index",
|
47
39
|
hook: "enqueue"
|
48
40
|
),
|
49
41
|
timestamp: 1_514_797_200
|
@@ -57,7 +49,6 @@ RSpec.describe "ActiveJob enqueue metrics", type: :request do
|
|
57
49
|
|
58
50
|
expect_no_metric(
|
59
51
|
tags: a_hash_including(
|
60
|
-
location: "MetricsController#index",
|
61
52
|
hook: "enqueue"
|
62
53
|
)
|
63
54
|
)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
1
|
+
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "ActiveJobs perform metrics", type: :request do
|
4
4
|
let(:tags_middleware) do
|
@@ -20,14 +20,10 @@ RSpec.describe "ActiveJobs perform metrics", type: :request do
|
|
20
20
|
|
21
21
|
expect_metric(
|
22
22
|
tags: a_hash_including(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
queue: "default",
|
28
|
-
server: Socket.gethostname,
|
29
|
-
app_name: :app_name,
|
30
|
-
tags_middleware: :tags_middleware
|
23
|
+
hook: "perform",
|
24
|
+
state: "succeeded",
|
25
|
+
job: "MetricJob",
|
26
|
+
queue: "default"
|
31
27
|
),
|
32
28
|
values: a_hash_including(
|
33
29
|
value: be_between(0, 30)
|
@@ -44,7 +40,6 @@ RSpec.describe "ActiveJobs perform metrics", type: :request do
|
|
44
40
|
|
45
41
|
expect_metric(
|
46
42
|
tags: a_hash_including(
|
47
|
-
location: "MetricsController#index",
|
48
43
|
hook: "perform"
|
49
44
|
),
|
50
45
|
timestamp: 1_514_797_200
|
@@ -60,7 +55,6 @@ RSpec.describe "ActiveJobs perform metrics", type: :request do
|
|
60
55
|
|
61
56
|
expect_no_metric(
|
62
57
|
tags: a_hash_including(
|
63
|
-
location: "MetricsController#index",
|
64
58
|
hook: "perform"
|
65
59
|
)
|
66
60
|
)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
1
|
+
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "ActiveRecord instantiation metrics", type: :request do
|
4
4
|
let(:tags_middleware) do
|
@@ -19,19 +19,12 @@ RSpec.describe "ActiveRecord instantiation metrics", type: :request do
|
|
19
19
|
|
20
20
|
expect_metric(
|
21
21
|
tags: a_hash_including(
|
22
|
-
|
23
|
-
|
24
|
-
class_name: "Metric",
|
25
|
-
additional_tag: :value,
|
26
|
-
server: Socket.gethostname,
|
27
|
-
app_name: :app_name,
|
28
|
-
tags_middleware: :tags_middleware
|
22
|
+
hook: "instantiation",
|
23
|
+
class_name: "Metric"
|
29
24
|
),
|
30
25
|
values: a_hash_including(
|
31
|
-
|
32
|
-
|
33
|
-
value: be_between(1, 30),
|
34
|
-
record_count: 1
|
26
|
+
value: be_between(1, 500),
|
27
|
+
record_count: 1
|
35
28
|
)
|
36
29
|
)
|
37
30
|
end
|
@@ -43,8 +36,7 @@ RSpec.describe "ActiveRecord instantiation metrics", type: :request do
|
|
43
36
|
|
44
37
|
expect_metric(
|
45
38
|
tags: a_hash_including(
|
46
|
-
|
47
|
-
hook: "instantiation"
|
39
|
+
hook: "instantiation"
|
48
40
|
),
|
49
41
|
timestamp: 1_514_797_200
|
50
42
|
)
|
@@ -57,8 +49,7 @@ RSpec.describe "ActiveRecord instantiation metrics", type: :request do
|
|
57
49
|
|
58
50
|
expect_no_metric(
|
59
51
|
tags: a_hash_including(
|
60
|
-
|
61
|
-
hook: "instantiation"
|
52
|
+
hook: "instantiation"
|
62
53
|
)
|
63
54
|
)
|
64
55
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
1
|
+
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "ActiveRecord SQL metrics", type: :request do
|
4
4
|
let(:tags_middleware) do
|
@@ -19,21 +19,14 @@ RSpec.describe "ActiveRecord SQL metrics", type: :request do
|
|
19
19
|
|
20
20
|
expect_metric(
|
21
21
|
tags: a_hash_including(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
operation: "INSERT",
|
27
|
-
additional_tag: :value,
|
28
|
-
server: Socket.gethostname,
|
29
|
-
app_name: :app_name,
|
30
|
-
tags_middleware: :tags_middleware
|
22
|
+
hook: "sql",
|
23
|
+
name: "Metric Create",
|
24
|
+
class_name: "Metric",
|
25
|
+
operation: "INSERT"
|
31
26
|
),
|
32
27
|
values: a_hash_including(
|
33
|
-
|
34
|
-
|
35
|
-
value: be_between(1, 30),
|
36
|
-
sql: "INSERT INTO \"metrics\" (\"name\", \"created_at\", \"updated_at\") VALUES (xxx)"
|
28
|
+
value: be_between(1, 500),
|
29
|
+
sql: "INSERT INTO \"metrics\" (\"name\", \"created_at\", \"updated_at\") VALUES (xxx)"
|
37
30
|
)
|
38
31
|
)
|
39
32
|
end
|
@@ -45,21 +38,14 @@ RSpec.describe "ActiveRecord SQL metrics", type: :request do
|
|
45
38
|
|
46
39
|
expect_metric(
|
47
40
|
tags: a_hash_including(
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
operation: "INSERT",
|
53
|
-
additional_tag: :value,
|
54
|
-
server: Socket.gethostname,
|
55
|
-
app_name: :app_name,
|
56
|
-
tags_middleware: :tags_middleware
|
41
|
+
hook: "sql",
|
42
|
+
name: "SQL",
|
43
|
+
class_name: "SQL",
|
44
|
+
operation: "INSERT"
|
57
45
|
),
|
58
46
|
values: a_hash_including(
|
59
|
-
|
60
|
-
|
61
|
-
value: be_between(1, 30),
|
62
|
-
sql: "INSERT INTO \"metrics\" (\"name\", \"created_at\", \"updated_at\") VALUES (xxx)"
|
47
|
+
value: be_between(1, 500),
|
48
|
+
sql: "INSERT INTO \"metrics\" (\"name\", \"created_at\", \"updated_at\") VALUES (xxx)"
|
63
49
|
)
|
64
50
|
)
|
65
51
|
end
|
@@ -71,7 +57,6 @@ RSpec.describe "ActiveRecord SQL metrics", type: :request do
|
|
71
57
|
|
72
58
|
expect_metric(
|
73
59
|
tags: a_hash_including(
|
74
|
-
location: "MetricsController#index",
|
75
60
|
hook: "sql"
|
76
61
|
),
|
77
62
|
timestamp: 1_514_797_200
|
@@ -85,7 +70,6 @@ RSpec.describe "ActiveRecord SQL metrics", type: :request do
|
|
85
70
|
|
86
71
|
expect_no_metric(
|
87
72
|
tags: a_hash_including(
|
88
|
-
location: "MetricsController#index",
|
89
73
|
hook: "sql"
|
90
74
|
)
|
91
75
|
)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
1
|
+
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "BlockInstrumentation metrics", type: :request do
|
4
4
|
let(:tags_middleware) do
|
@@ -17,20 +17,13 @@ RSpec.describe "BlockInstrumentation metrics", type: :request do
|
|
17
17
|
|
18
18
|
expect_metric(
|
19
19
|
tags: a_hash_including(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
server: Socket.gethostname,
|
24
|
-
app_name: :app_name,
|
25
|
-
tags_middleware: :tags_middleware,
|
26
|
-
block_tag: :block_tag,
|
27
|
-
name: "name"
|
20
|
+
hook: "block_instrumentation",
|
21
|
+
block_tag: :block_tag,
|
22
|
+
name: "name"
|
28
23
|
),
|
29
24
|
values: a_hash_including(
|
30
|
-
|
31
|
-
|
32
|
-
block_value: :block_value,
|
33
|
-
value: be_between(1, 30)
|
25
|
+
block_value: :block_value,
|
26
|
+
value: be_between(1, 500)
|
34
27
|
)
|
35
28
|
)
|
36
29
|
end
|
@@ -42,8 +35,7 @@ RSpec.describe "BlockInstrumentation metrics", type: :request do
|
|
42
35
|
|
43
36
|
expect_metric(
|
44
37
|
tags: a_hash_including(
|
45
|
-
|
46
|
-
hook: "block_instrumentation"
|
38
|
+
hook: "block_instrumentation"
|
47
39
|
),
|
48
40
|
timestamp: 1_514_797_200
|
49
41
|
)
|
@@ -56,8 +48,7 @@ RSpec.describe "BlockInstrumentation metrics", type: :request do
|
|
56
48
|
|
57
49
|
expect_no_metric(
|
58
50
|
tags: a_hash_including(
|
59
|
-
|
60
|
-
hook: "block_instrumentation"
|
51
|
+
hook: "block_instrumentation"
|
61
52
|
)
|
62
53
|
)
|
63
54
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
3
|
require "active_support"
|
4
4
|
require_relative "../lib/influxdb/rails/helpers/rspec_matchers"
|
5
|
-
require File.expand_path(File.dirname(__FILE__)
|
5
|
+
require File.expand_path("#{File.dirname(__FILE__)}/support/broken_client")
|
6
6
|
|
7
7
|
ENV["RAILS_ENV"] ||= "test"
|
8
8
|
|
@@ -34,6 +34,7 @@ RSpec.configure do |config|
|
|
34
34
|
end
|
35
35
|
|
36
36
|
config.include ActiveSupport::Testing::TimeHelpers
|
37
|
+
config.include ActiveSupport::Testing::Assertions
|
37
38
|
config.include ActiveJob::TestHelper
|
38
39
|
|
39
40
|
config.include InfluxDB::Rails::BrokenClient
|
data/spec/support/rails5/app.rb
CHANGED
@@ -20,9 +20,6 @@ app.routes.draw do
|
|
20
20
|
resources :exceptions, only: :index
|
21
21
|
end
|
22
22
|
|
23
|
-
InfluxDB::Rails.configure do |config|
|
24
|
-
end
|
25
|
-
|
26
23
|
ENV["DATABASE_URL"] = "sqlite3::memory:"
|
27
24
|
ActiveRecord::Schema.define do
|
28
25
|
create_table :metrics, force: true do |t|
|
@@ -52,7 +49,9 @@ class MetricMailer < ActionMailer::Base
|
|
52
49
|
end
|
53
50
|
|
54
51
|
class Metric < ActiveRecord::Base; end
|
52
|
+
|
55
53
|
class ApplicationController < ActionController::Base; end
|
54
|
+
|
56
55
|
class MetricsController < ApplicationController
|
57
56
|
prepend_view_path File.join(__dir__, "..", "views")
|
58
57
|
|
@@ -77,7 +76,7 @@ end
|
|
77
76
|
|
78
77
|
class ExceptionsController < ApplicationController
|
79
78
|
def index
|
80
|
-
|
79
|
+
raise ActiveRecord::RecordNotFound
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
data/spec/support/rails6/app.rb
CHANGED
@@ -20,9 +20,6 @@ app.routes.draw do
|
|
20
20
|
resources :exceptions, only: :index
|
21
21
|
end
|
22
22
|
|
23
|
-
InfluxDB::Rails.configure do |config|
|
24
|
-
end
|
25
|
-
|
26
23
|
ENV["DATABASE_URL"] = "sqlite3::memory:"
|
27
24
|
ActiveRecord::Schema.define do
|
28
25
|
create_table :metrics, force: true do |t|
|
@@ -52,7 +49,9 @@ class MetricMailer < ActionMailer::Base
|
|
52
49
|
end
|
53
50
|
|
54
51
|
class Metric < ActiveRecord::Base; end
|
52
|
+
|
55
53
|
class ApplicationController < ActionController::Base; end
|
54
|
+
|
56
55
|
class MetricsController < ApplicationController
|
57
56
|
prepend_view_path File.join(__dir__, "..", "views")
|
58
57
|
|
@@ -77,7 +76,7 @@ end
|
|
77
76
|
|
78
77
|
class ExceptionsController < ApplicationController
|
79
78
|
def index
|
80
|
-
|
79
|
+
raise ActiveRecord::RecordNotFound
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|