influxdb-rails 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e3add8b49d3fbf1997dc07754f80def0d41912c63547089ecba0b2d3eb1e7d5
4
- data.tar.gz: 20b896a9146f74b8dfd2ea3ee5b5e8461a41efbf189304b5e2c98a1c9a02458d
3
+ metadata.gz: bd28d1ed1a585a6ad1aef9945e693b2b1d20668de731e35ab0066c2c09ed50a5
4
+ data.tar.gz: df3e81593ce080e308018b2f94ea4ff4e3094f3584843051c60d6219ed9fe7aa
5
5
  SHA512:
6
- metadata.gz: 97433217a36b42704ceed5fb5656f2ffbf11dbd0d08bbd17a14972355ba6fe63ed1c4382d789f0691c3496a95b5e4ff8e388399ce4876614c237add03ed27926
7
- data.tar.gz: b8f0b71d8ba29926e7924489b69b4a199c24a821bc2f0268b804714f44c946aecc3fcf3115305ddab23eccd092efdebb6f77c3d71616d7de8b8226288d7c2832
6
+ metadata.gz: 8cbea1f68ee5ad8b68f9b8a4ee953999215bf62f6300aff3fb7b679f6d5fa797a49a2c28f9d0d2f0594f14cc15955d34291b6344371ad141d107d6dc8ff7a8c2
7
+ data.tar.gz: 6723fc68b1ba75a1efd39e820e9752e757bbb34007763b832ea565942716606a6ee388bfdb967dbabd4790eefb9b7414e6dc0697b7d6388454713b4b879700f6
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- For the full commit log, [see here](https://github.com/influxdata/influxdb-rails/commits/master).
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.
4
8
 
5
9
  ## v1.0.1, released 2021-03-23
6
10
 
@@ -9,7 +9,7 @@ module InfluxDB
9
9
 
10
10
  def to_h
11
11
  expanded_tags.reject do |_, value|
12
- value.blank?
12
+ value.to_s.blank?
13
13
  end
14
14
  end
15
15
 
@@ -8,7 +8,7 @@ module InfluxDB
8
8
 
9
9
  def to_h
10
10
  expanded_values.reject do |_, value|
11
- value.blank?
11
+ value.to_s.blank?
12
12
  end
13
13
  end
14
14
 
@@ -1,5 +1,5 @@
1
1
  module InfluxDB
2
2
  module Rails
3
- VERSION = "1.0.1".freeze
3
+ VERSION = "1.0.2".freeze
4
4
  end
5
5
  end
@@ -18,11 +18,27 @@ RSpec.describe "ActionController metrics", type: :request do
18
18
  expect_metric(
19
19
  name: "rails",
20
20
  tags: a_hash_including(
21
- method: "MetricsController#index",
21
+ hook: "process_action",
22
+ status: 200,
23
+ format: :html,
24
+ http_method: "GET"
25
+ ),
26
+ values: a_hash_including(
27
+ view: be_between(1, 500),
28
+ db: be_between(1, 500),
29
+ controller: be_between(1, 500)
30
+ )
31
+ )
32
+ end
33
+
34
+ it "writes default and custom tags" do
35
+ get "/metrics"
36
+
37
+ expect_metric(
38
+ name: "rails",
39
+ tags: a_hash_including(
22
40
  hook: "process_action",
23
- status: 200,
24
- format: :html,
25
- http_method: "GET",
41
+ location: "MetricsController#index",
26
42
  additional_tag: :value,
27
43
  server: Socket.gethostname,
28
44
  app_name: :app_name,
@@ -30,10 +46,7 @@ RSpec.describe "ActionController metrics", type: :request do
30
46
  ),
31
47
  values: a_hash_including(
32
48
  additional_value: :value,
33
- request_id: :request_id,
34
- view: be_between(1, 500),
35
- db: be_between(1, 500),
36
- controller: be_between(1, 500)
49
+ request_id: :request_id
37
50
  )
38
51
  )
39
52
  end
@@ -18,18 +18,11 @@ RSpec.describe "ActionMailer deliver metrics", type: :request do
18
18
 
19
19
  expect_metric(
20
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
21
+ hook: "deliver",
22
+ mailer: "MetricMailer"
28
23
  ),
29
24
  values: a_hash_including(
30
- additional_value: :value,
31
- request_id: :request_id,
32
- value: 1
25
+ value: 1
33
26
  )
34
27
  )
35
28
  end
@@ -18,19 +18,12 @@ RSpec.describe "ActionView collection metrics", type: :request do
18
18
  expect_metric(
19
19
  name: "rails",
20
20
  tags: a_hash_including(
21
- location: "MetricsController#index",
22
- hook: "render_collection",
23
- additional_tag: :value,
24
- filename: include("spec/support/views/metrics/_item.html.erb"),
25
- server: Socket.gethostname,
26
- app_name: :app_name,
27
- tags_middleware: :tags_middleware
21
+ hook: "render_collection",
22
+ filename: include("spec/support/views/metrics/_item.html.erb")
28
23
  ),
29
24
  values: a_hash_including(
30
- additional_value: :value,
31
- count: 3,
32
- request_id: :request_id,
33
- value: be_between(1, 500)
25
+ count: 3,
26
+ value: be_between(1, 500)
34
27
  )
35
28
  )
36
29
  end
@@ -43,8 +36,7 @@ RSpec.describe "ActionView collection metrics", type: :request do
43
36
  expect_metric(
44
37
  name: "rails",
45
38
  tags: a_hash_including(
46
- location: "MetricsController#index",
47
- hook: "render_collection"
39
+ hook: "render_collection"
48
40
  ),
49
41
  timestamp: 1_514_797_200
50
42
  )
@@ -58,8 +50,7 @@ RSpec.describe "ActionView collection metrics", type: :request do
58
50
  expect_no_metric(
59
51
  name: "rails",
60
52
  tags: a_hash_including(
61
- location: "MetricsController#index",
62
- hook: "render_collection"
53
+ hook: "render_collection"
63
54
  )
64
55
  )
65
56
  end
@@ -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
- location: "MetricsController#index",
21
- hook: "render_partial",
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
- additional_value: :value,
30
- request_id: :request_id,
31
- value: be_between(1, 500)
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
- location: "MetricsController#index",
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
- location: "MetricsController#index",
58
- hook: "render_partial"
49
+ hook: "render_partial"
59
50
  )
60
51
  )
61
52
  end
@@ -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
- location: "MetricsController#index",
21
- hook: "render_template",
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
- additional_value: :value,
30
- request_id: :request_id,
31
- value: be_between(1, 500)
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
- location: "MetricsController#index",
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
- location: "MetricsController#index",
58
- hook: "render_template"
49
+ hook: "render_template"
59
50
  )
60
51
  )
61
52
  end
@@ -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
- location: "MetricsController#index",
22
- hook: "enqueue",
23
- job: "MetricJob",
24
- queue: "default",
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
- additional_value: :value,
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
  )
@@ -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
- location: "MetricsController#index",
24
- hook: "perform",
25
- state: "succeeded",
26
- job: "MetricJob",
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
  )
@@ -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
- location: "MetricsController#show",
23
- hook: "instantiation",
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
- additional_value: :value,
32
- request_id: :request_id,
33
- value: be_between(1, 500),
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
- location: "MetricsController#show",
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
- location: "MetricsController#show",
61
- hook: "instantiation"
52
+ hook: "instantiation"
62
53
  )
63
54
  )
64
55
  end
@@ -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
- location: "MetricsController#index",
23
- hook: "sql",
24
- name: "Metric Create",
25
- class_name: "Metric",
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
- additional_value: :value,
34
- request_id: :request_id,
35
- value: be_between(1, 500),
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
- location: "MetricsController#index",
49
- hook: "sql",
50
- name: "SQL",
51
- class_name: "SQL",
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
- additional_value: :value,
60
- request_id: :request_id,
61
- value: be_between(1, 500),
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
  )
@@ -17,20 +17,13 @@ RSpec.describe "BlockInstrumentation metrics", type: :request do
17
17
 
18
18
  expect_metric(
19
19
  tags: a_hash_including(
20
- location: "MetricsController#index",
21
- hook: "block_instrumentation",
22
- additional_tag: :value,
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
- additional_value: :value,
31
- request_id: :request_id,
32
- block_value: :block_value,
33
- value: be_between(1, 500)
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
- location: "MetricsController#index",
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
- location: "MetricsController#index",
60
- hook: "block_instrumentation"
51
+ hook: "block_instrumentation"
61
52
  )
62
53
  )
63
54
  end
data/spec/unit/tags.rb ADDED
@@ -0,0 +1,47 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe InfluxDB::Rails::Tags do
4
+ let(:config) { InfluxDB::Rails::Configuration.new }
5
+
6
+ describe ".to_h" do
7
+ it "returns TrueClass" do
8
+ subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: true })
9
+ expect(subject.to_h).to a_hash_including(hans: true)
10
+ end
11
+
12
+ it "returns FalseClass" do
13
+ subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: false })
14
+ expect(subject.to_h).to a_hash_including(hans: false)
15
+ end
16
+
17
+ it "returns strings" do
18
+ subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: "franz" })
19
+ expect(subject.to_h).to a_hash_including(hans: "franz")
20
+ end
21
+
22
+ it "returns strings containing blank" do
23
+ subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: "franz hans" })
24
+ expect(subject.to_h).to a_hash_including(hans: "franz hans")
25
+ end
26
+
27
+ it "removes empty strings" do
28
+ subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: "", franz: " " })
29
+ expect(subject.to_h).not_to a_hash_including(hans: "", franz: " ")
30
+ end
31
+
32
+ it "returns symbols" do
33
+ subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: :franz })
34
+ expect(subject.to_h).to a_hash_including(hans: :franz)
35
+ end
36
+
37
+ it "removes nil" do
38
+ subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: nil })
39
+ expect(subject.to_h).not_to a_hash_including(hans: nil)
40
+ end
41
+
42
+ it "leaves arrays alone" do
43
+ subject = InfluxDB::Rails::Tags.new(config: config, tags: { hans: [], franz: %w[a b] })
44
+ expect(subject.to_h).to a_hash_including(hans: [], franz: %w[a b])
45
+ end
46
+ end
47
+ end
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.2
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: 2021-03-23 00:00:00.000000000 Z
12
+ date: 2021-04-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: influxdb
@@ -333,6 +333,7 @@ files:
333
333
  - spec/unit/configuration_spec.rb
334
334
  - spec/unit/sql/normalizer_spec.rb
335
335
  - spec/unit/sql/query_spec.rb
336
+ - spec/unit/tags.rb
336
337
  homepage: https://influxdata.com
337
338
  licenses:
338
339
  - MIT
@@ -385,3 +386,4 @@ test_files:
385
386
  - spec/unit/configuration_spec.rb
386
387
  - spec/unit/sql/normalizer_spec.rb
387
388
  - spec/unit/sql/query_spec.rb
389
+ - spec/unit/tags.rb