influxdb-rails 1.0.1.beta2 → 1.0.1.beta3
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 +31 -0
- data/.rubocop.yml +34 -6
- data/CHANGELOG.md +3 -0
- data/README.md +3 -4
- data/gemfiles/Gemfile.rails-6.0.x +1 -2
- data/gemfiles/Gemfile.rails-6.1.x +9 -0
- data/influxdb-rails.gemspec +1 -1
- data/lib/influxdb-rails.rb +1 -2
- data/lib/influxdb/rails/middleware/active_job_subscriber.rb +11 -11
- data/lib/influxdb/rails/railtie.rb +0 -1
- data/lib/influxdb/rails/sql/normalizer.rb +3 -3
- data/lib/influxdb/rails/tags.rb +1 -1
- data/lib/influxdb/rails/version.rb +1 -1
- data/lib/rails/generators/influxdb/templates/initializer.rb +4 -0
- data/sample-dashboard/Rakefile +2 -2
- data/spec/requests/action_controller_metrics_spec.rb +4 -4
- data/spec/requests/action_mailer_deliver_metrics_spec.rb +1 -1
- data/spec/requests/action_view_collection_metrics_spec.rb +2 -2
- data/spec/requests/action_view_partial_metrics_spec.rb +2 -2
- data/spec/requests/action_view_template_metrics_spec.rb +2 -2
- data/spec/requests/active_job_enqueue_metrics_spec.rb +1 -1
- data/spec/requests/active_job_perform_metrics_spec.rb +1 -1
- data/spec/requests/active_record_instantiation_metrics_spec.rb +2 -2
- data/spec/requests/active_record_sql_metrics_spec.rb +3 -3
- data/spec/requests/block_inistrumentation_spec.rb +2 -2
- 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 +2 -3
- data/spec/support/rails6/app.rb +2 -3
- metadata +8 -9
- data/.travis.yml +0 -28
- data/spec/requests/active_job_perform_start_metrics_spec.rb +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fe64b1f95e624972f8ef34c23e3d3f3b9312d33bbdd8480c1ba630449edcc03
|
4
|
+
data.tar.gz: 95efa62efbc63f9d480cf896c8b6b37d32aebd27e9ca874fcb5d9542cdcf6de0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d730e69f948734211948092f47f2d089cde0a117e8cf50a4abd6de0a76f382f16f7e7da565547a5e6daf3740aa806ba2376f2dfe8145c4d61749639bdc095e7
|
7
|
+
data.tar.gz: 25e4085b54c19d22e6fa06bc09f52243fe1d4cc932de513deebafe922b6c415eed2a0250d120a663bdd5621401669a9eba922178e2136b519d2c98124e7fe63a
|
@@ -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,31 @@
|
|
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', '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: 'head', rails: 'gemfiles/Gemfile.rails-5.2.x' }
|
19
|
+
- { ruby: '2.5', rails: 'gemfiles/Gemfile.rails-6.0.x' }
|
20
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
21
|
+
env:
|
22
|
+
BUNDLE_GEMFILE: ${{ matrix.rails }}
|
23
|
+
name: Ruby ${{ matrix.ruby }} ${{ matrix.rails }} specs
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
ruby-version: ${{ matrix.ruby }}
|
29
|
+
bundler-cache: true
|
30
|
+
- name: Run tests
|
31
|
+
run: bundle exec rake spec
|
data/.rubocop.yml
CHANGED
@@ -13,16 +13,13 @@ AllCops:
|
|
13
13
|
StyleGuideCopsOnly: false
|
14
14
|
TargetRubyVersion: 2.4
|
15
15
|
|
16
|
-
Rails:
|
17
|
-
Enabled: false
|
18
|
-
|
19
16
|
Layout/EmptyLinesAroundArguments:
|
20
17
|
Enabled: false
|
21
18
|
|
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
@@ -2,6 +2,9 @@
|
|
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.beta3, release 2020-10-16
|
6
|
+
- Drop `perform_start.active_job` subscriber, it's rather useless on dashboards.
|
7
|
+
|
5
8
|
## v1.0.1.beta2, released 2020-09-14
|
6
9
|
- Implement [`deliver.action_mailer`](https://guides.rubyonrails.org/active_support_instrumentation.html#deliver-action-mailer) subscriber
|
7
10
|
- Add missing Active Job documentation
|
data/README.md
CHANGED
@@ -137,7 +137,6 @@ Reported tags:
|
|
137
137
|
Reported ActiveSupport instrumentation hooks:
|
138
138
|
|
139
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
140
|
- [perform.active\_job](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-active-job)
|
142
141
|
|
143
142
|
Reported values:
|
@@ -149,14 +148,14 @@ Reported values:
|
|
149
148
|
Reported tags:
|
150
149
|
|
151
150
|
```ruby
|
152
|
-
hook: ["enqueue", "
|
153
|
-
state: ["queued", "
|
151
|
+
hook: ["enqueue", "perform"],
|
152
|
+
state: ["queued", "succeeded", "failed"],
|
154
153
|
job: "SomeJobClassName",
|
155
154
|
queue: "queue_name"
|
156
155
|
```
|
157
156
|
|
158
157
|
*Note*: Only the measurements with the hook `perform` report a duration in the value.
|
159
|
-
The
|
158
|
+
The enqueue hook is a counter and always reports a value of `1`.
|
160
159
|
|
161
160
|
### Action Mailer
|
162
161
|
|
data/influxdb-rails.gemspec
CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_development_dependency "rdoc"
|
39
39
|
spec.add_development_dependency "rspec"
|
40
40
|
spec.add_development_dependency "rspec-rails", ">= 3.0.0"
|
41
|
-
spec.add_development_dependency "rubocop", "~>
|
41
|
+
spec.add_development_dependency "rubocop", "~> 1.7.0"
|
42
42
|
spec.add_development_dependency "sqlite3"
|
43
43
|
spec.add_development_dependency "tzinfo"
|
44
44
|
end
|
data/lib/influxdb-rails.rb
CHANGED
@@ -6,6 +6,13 @@ module InfluxDB
|
|
6
6
|
class ActiveJobSubscriber < Subscriber # :nodoc:
|
7
7
|
private
|
8
8
|
|
9
|
+
JOB_STATE = {
|
10
|
+
"enqueue" => "queued",
|
11
|
+
"perform_start" => "running",
|
12
|
+
"perform" => "succeeded",
|
13
|
+
}.freeze
|
14
|
+
private_constant :JOB_STATE
|
15
|
+
|
9
16
|
def values
|
10
17
|
{
|
11
18
|
value: value,
|
@@ -24,14 +31,7 @@ module InfluxDB
|
|
24
31
|
def job_state
|
25
32
|
return "failed" if failed?
|
26
33
|
|
27
|
-
|
28
|
-
when "enqueue"
|
29
|
-
"queued"
|
30
|
-
when "perform_start"
|
31
|
-
"running"
|
32
|
-
when "perform"
|
33
|
-
"succeeded"
|
34
|
-
end
|
34
|
+
JOB_STATE[short_hook_name]
|
35
35
|
end
|
36
36
|
|
37
37
|
def measure_performance?
|
@@ -44,8 +44,8 @@ module InfluxDB
|
|
44
44
|
|
45
45
|
def fetch_short_hook_name
|
46
46
|
return "enqueue" if hook_name.include?("enqueue")
|
47
|
-
|
48
|
-
|
47
|
+
|
48
|
+
"perform"
|
49
49
|
end
|
50
50
|
|
51
51
|
def job
|
@@ -59,7 +59,7 @@ module InfluxDB
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def failed?
|
62
|
-
payload[:
|
62
|
+
payload[:aborted]
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -32,7 +32,6 @@ module InfluxDB
|
|
32
32
|
"sql.active_record" => Middleware::SqlSubscriber,
|
33
33
|
"instantiation.active_record" => Middleware::ActiveRecordSubscriber,
|
34
34
|
"enqueue.active_job" => Middleware::ActiveJobSubscriber,
|
35
|
-
"perform_start.active_job" => Middleware::ActiveJobSubscriber,
|
36
35
|
"perform.active_job" => Middleware::ActiveJobSubscriber,
|
37
36
|
"deliver.action_mailer" => Middleware::ActionMailerSubscriber,
|
38
37
|
"block_instrumentation.influxdb_rails" => Middleware::BlockInstrumentationSubscriber,
|
@@ -8,9 +8,9 @@ module InfluxDB
|
|
8
8
|
|
9
9
|
def perform
|
10
10
|
query.squish!
|
11
|
-
query.gsub!(/(\s(=|>|<|>=|<=|<>|!=)\s)('[^']+'|[
|
12
|
-
query.gsub!(/(\sIN\s)\([
|
13
|
-
regex = /(\sBETWEEN\s)('[^']+'|[
|
11
|
+
query.gsub!(/(\s(=|>|<|>=|<=|<>|!=)\s)('[^']+'|[$+\-\w.]+)/, '\1xxx')
|
12
|
+
query.gsub!(/(\sIN\s)\([^()]+\)/i, '\1(xxx)')
|
13
|
+
regex = /(\sBETWEEN\s)('[^']+'|[+\-\w.]+)(\sAND\s)('[^']+'|[+\-\w.]+)/i
|
14
14
|
query.gsub!(regex, '\1xxx\3xxx')
|
15
15
|
query.gsub!(/(\sVALUES\s)\(.+\)/i, '\1(xxx)')
|
16
16
|
query.gsub!(/(\s(LIKE|ILIKE|SIMILAR TO|NOT SIMILAR TO)\s)('[^']+')/i, '\1xxx')
|
data/lib/influxdb/rails/tags.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module InfluxDB
|
2
2
|
module Rails
|
3
3
|
class Tags
|
4
|
-
def initialize(tags: {},
|
4
|
+
def initialize(config:, tags: {}, additional_tags: InfluxDB::Rails.current.tags)
|
5
5
|
@tags = tags
|
6
6
|
@config = config
|
7
7
|
@additional_tags = additional_tags
|
@@ -11,6 +11,10 @@ InfluxDB::Rails.configure do |config|
|
|
11
11
|
# config.client.username = "root"
|
12
12
|
# config.client.password = "root"
|
13
13
|
|
14
|
+
## If your InfluxDB service requires an HTTPS connection then you can
|
15
|
+
## enable it here.
|
16
|
+
# config.client.use_ssl = true
|
17
|
+
|
14
18
|
## Various other client and connection options. These are used to create
|
15
19
|
## an `InfluxDB::Client` instance (i.e. `InfluxDB::Rails.client`).
|
16
20
|
##
|
data/sample-dashboard/Rakefile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
task default: %w[prepare]
|
2
2
|
|
3
|
-
# rubocop:disable
|
3
|
+
# rubocop:disable Layout/LineLength
|
4
4
|
task :prepare do
|
5
5
|
sh "cat 'Ruby On Rails Performance.json' | sed 's/${DS_INFLUXDB}/InfluxDB/g' > provisioning/performance.json"
|
6
6
|
sh "cat 'Ruby On Rails Performance (per Request).json' | sed 's/${DS_INFLUXDB}/InfluxDB/g' > provisioning/performance-request.json"
|
7
7
|
sh "cat 'Ruby On Rails Performance (per Action).json' | sed 's/${DS_INFLUXDB}/InfluxDB/g' > provisioning/performance-action.json"
|
8
8
|
end
|
9
|
-
# rubocop:enable
|
9
|
+
# rubocop:enable Layout/LineLength
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
1
|
+
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "ActionController metrics", type: :request do
|
4
4
|
let(:tags_middleware) do
|
@@ -31,9 +31,9 @@ RSpec.describe "ActionController metrics", type: :request do
|
|
31
31
|
values: a_hash_including(
|
32
32
|
additional_value: :value,
|
33
33
|
request_id: :request_id,
|
34
|
-
view: be_between(1,
|
35
|
-
db: be_between(1,
|
36
|
-
controller: be_between(1,
|
34
|
+
view: be_between(1, 500),
|
35
|
+
db: be_between(1, 500),
|
36
|
+
controller: be_between(1, 500)
|
37
37
|
)
|
38
38
|
)
|
39
39
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
1
|
+
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "ActionView collection metrics", type: :request do
|
4
4
|
let(:tags_middleware) do
|
@@ -30,7 +30,7 @@ RSpec.describe "ActionView collection metrics", type: :request do
|
|
30
30
|
additional_value: :value,
|
31
31
|
count: 3,
|
32
32
|
request_id: :request_id,
|
33
|
-
value: be_between(1,
|
33
|
+
value: be_between(1, 500)
|
34
34
|
)
|
35
35
|
)
|
36
36
|
end
|
@@ -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
|
@@ -28,7 +28,7 @@ RSpec.describe "ActionView partial metrics", type: :request do
|
|
28
28
|
values: a_hash_including(
|
29
29
|
additional_value: :value,
|
30
30
|
request_id: :request_id,
|
31
|
-
value: be_between(1,
|
31
|
+
value: be_between(1, 500)
|
32
32
|
)
|
33
33
|
)
|
34
34
|
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
|
@@ -28,7 +28,7 @@ RSpec.describe "ActionView template metrics", type: :request do
|
|
28
28
|
values: a_hash_including(
|
29
29
|
additional_value: :value,
|
30
30
|
request_id: :request_id,
|
31
|
-
value: be_between(1,
|
31
|
+
value: be_between(1, 500)
|
32
32
|
)
|
33
33
|
)
|
34
34
|
end
|
@@ -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
|
@@ -30,7 +30,7 @@ RSpec.describe "ActiveRecord instantiation metrics", type: :request do
|
|
30
30
|
values: a_hash_including(
|
31
31
|
additional_value: :value,
|
32
32
|
request_id: :request_id,
|
33
|
-
value: be_between(1,
|
33
|
+
value: be_between(1, 500),
|
34
34
|
record_count: 1
|
35
35
|
)
|
36
36
|
)
|
@@ -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
|
@@ -32,7 +32,7 @@ RSpec.describe "ActiveRecord SQL metrics", type: :request do
|
|
32
32
|
values: a_hash_including(
|
33
33
|
additional_value: :value,
|
34
34
|
request_id: :request_id,
|
35
|
-
value: be_between(1,
|
35
|
+
value: be_between(1, 500),
|
36
36
|
sql: "INSERT INTO \"metrics\" (\"name\", \"created_at\", \"updated_at\") VALUES (xxx)"
|
37
37
|
)
|
38
38
|
)
|
@@ -58,7 +58,7 @@ RSpec.describe "ActiveRecord SQL metrics", type: :request do
|
|
58
58
|
values: a_hash_including(
|
59
59
|
additional_value: :value,
|
60
60
|
request_id: :request_id,
|
61
|
-
value: be_between(1,
|
61
|
+
value: be_between(1, 500),
|
62
62
|
sql: "INSERT INTO \"metrics\" (\"name\", \"created_at\", \"updated_at\") VALUES (xxx)"
|
63
63
|
)
|
64
64
|
)
|
@@ -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
|
@@ -30,7 +30,7 @@ RSpec.describe "BlockInstrumentation metrics", type: :request do
|
|
30
30
|
additional_value: :value,
|
31
31
|
request_id: :request_id,
|
32
32
|
block_value: :block_value,
|
33
|
-
value: be_between(1,
|
33
|
+
value: be_between(1, 500)
|
34
34
|
)
|
35
35
|
)
|
36
36
|
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
|
|
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
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Bruckmayer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: influxdb
|
@@ -205,14 +205,14 @@ dependencies:
|
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
208
|
+
version: 1.7.0
|
209
209
|
type: :development
|
210
210
|
prerelease: false
|
211
211
|
version_requirements: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
213
|
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version:
|
215
|
+
version: 1.7.0
|
216
216
|
- !ruby/object:Gem::Dependency
|
217
217
|
name: sqlite3
|
218
218
|
requirement: !ruby/object:Gem::Requirement
|
@@ -250,10 +250,11 @@ extensions: []
|
|
250
250
|
extra_rdoc_files: []
|
251
251
|
files:
|
252
252
|
- ".github/dependabot.yml"
|
253
|
+
- ".github/workflows/rubocop.yml"
|
254
|
+
- ".github/workflows/spec.yml"
|
253
255
|
- ".gitignore"
|
254
256
|
- ".rspec"
|
255
257
|
- ".rubocop.yml"
|
256
|
-
- ".travis.yml"
|
257
258
|
- CHANGELOG.md
|
258
259
|
- Gemfile
|
259
260
|
- LICENSE.txt
|
@@ -262,6 +263,7 @@ files:
|
|
262
263
|
- config.ru
|
263
264
|
- gemfiles/Gemfile.rails-5.2.x
|
264
265
|
- gemfiles/Gemfile.rails-6.0.x
|
266
|
+
- gemfiles/Gemfile.rails-6.1.x
|
265
267
|
- influxdb-rails.gemspec
|
266
268
|
- lib/influxdb-rails.rb
|
267
269
|
- lib/influxdb/rails/configuration.rb
|
@@ -304,7 +306,6 @@ files:
|
|
304
306
|
- spec/requests/action_view_template_metrics_spec.rb
|
305
307
|
- spec/requests/active_job_enqueue_metrics_spec.rb
|
306
308
|
- spec/requests/active_job_perform_metrics_spec.rb
|
307
|
-
- spec/requests/active_job_perform_start_metrics_spec.rb
|
308
309
|
- spec/requests/active_record_instantiation_metrics_spec.rb
|
309
310
|
- spec/requests/active_record_sql_metrics_spec.rb
|
310
311
|
- spec/requests/block_inistrumentation_spec.rb
|
@@ -345,8 +346,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
345
346
|
- !ruby/object:Gem::Version
|
346
347
|
version: 1.3.1
|
347
348
|
requirements: []
|
348
|
-
|
349
|
-
rubygems_version: 2.7.6.2
|
349
|
+
rubygems_version: 3.1.4
|
350
350
|
signing_key:
|
351
351
|
specification_version: 4
|
352
352
|
summary: InfluxDB bindings for Ruby on Rails.
|
@@ -358,7 +358,6 @@ test_files:
|
|
358
358
|
- spec/requests/action_view_template_metrics_spec.rb
|
359
359
|
- spec/requests/active_job_enqueue_metrics_spec.rb
|
360
360
|
- spec/requests/active_job_perform_metrics_spec.rb
|
361
|
-
- spec/requests/active_job_perform_start_metrics_spec.rb
|
362
361
|
- spec/requests/active_record_instantiation_metrics_spec.rb
|
363
362
|
- spec/requests/active_record_sql_metrics_spec.rb
|
364
363
|
- spec/requests/block_inistrumentation_spec.rb
|
data/.travis.yml
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
sudo: required
|
2
|
-
dist: trusty
|
3
|
-
language: ruby
|
4
|
-
before_install:
|
5
|
-
- gem update --system --no-doc
|
6
|
-
- gem install bundler --no-doc
|
7
|
-
- gem update bundler --no-doc
|
8
|
-
rvm:
|
9
|
-
- ruby-head
|
10
|
-
- "2.7"
|
11
|
-
- "2.6"
|
12
|
-
- "2.5"
|
13
|
-
gemfile:
|
14
|
-
- gemfiles/Gemfile.rails-6.0.x
|
15
|
-
- gemfiles/Gemfile.rails-5.2.x
|
16
|
-
env:
|
17
|
-
- TEST_TASK=spec
|
18
|
-
matrix:
|
19
|
-
allow_failures:
|
20
|
-
- rvm: ruby-head
|
21
|
-
include:
|
22
|
-
- { rvm: "2.6", gemfile: "Gemfile", env: [TEST_TASK=rubocop] }
|
23
|
-
addons:
|
24
|
-
apt:
|
25
|
-
packages:
|
26
|
-
- haveged
|
27
|
-
- libgmp-dev
|
28
|
-
script: bundle exec rake $TEST_TASK
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "ActiveJob start 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
|
-
perform_enqueued_jobs do
|
18
|
-
get "/metrics"
|
19
|
-
end
|
20
|
-
|
21
|
-
expect_metric(
|
22
|
-
tags: a_hash_including(
|
23
|
-
location: "MetricsController#index",
|
24
|
-
hook: "perform_start",
|
25
|
-
state: "running",
|
26
|
-
job: "MetricJob",
|
27
|
-
queue: "default",
|
28
|
-
server: Socket.gethostname,
|
29
|
-
app_name: :app_name,
|
30
|
-
tags_middleware: :tags_middleware
|
31
|
-
),
|
32
|
-
values: a_hash_including(
|
33
|
-
value: 1
|
34
|
-
)
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "includes correct timestamps" do
|
39
|
-
travel_to Time.zone.local(2018, 1, 1, 9, 0, 0)
|
40
|
-
|
41
|
-
perform_enqueued_jobs do
|
42
|
-
get "/metrics"
|
43
|
-
end
|
44
|
-
|
45
|
-
expect_metric(
|
46
|
-
tags: a_hash_including(
|
47
|
-
location: "MetricsController#index",
|
48
|
-
hook: "perform_start"
|
49
|
-
),
|
50
|
-
timestamp: 1_514_797_200
|
51
|
-
)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "does not write metric when hook is ignored" do
|
55
|
-
allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:ignored_hooks).and_return(["perform_start.active_job"])
|
56
|
-
|
57
|
-
perform_enqueued_jobs do
|
58
|
-
get "/metrics"
|
59
|
-
end
|
60
|
-
|
61
|
-
expect_no_metric(
|
62
|
-
tags: a_hash_including(
|
63
|
-
location: "MetricsController#index",
|
64
|
-
hook: "perform_start"
|
65
|
-
)
|
66
|
-
)
|
67
|
-
end
|
68
|
-
end
|