Skip to content

Commit 0287553

Browse files
committed
Explicitely spec out default/custom tags
Do not expect them all the time, it's has become a bit too implicit.
1 parent 38d59b5 commit 0287553

10 files changed

+74
-144
lines changed

spec/requests/action_controller_metrics_spec.rb

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,35 @@
1818
expect_metric(
1919
name: "rails",
2020
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(
2240
hook: "process_action",
23-
status: 200,
24-
format: :html,
25-
http_method: "GET",
41+
location: "MetricsController#index",
2642
additional_tag: :value,
2743
server: Socket.gethostname,
2844
app_name: :app_name,
2945
tags_middleware: :tags_middleware
3046
),
3147
values: a_hash_including(
3248
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
3750
)
3851
)
3952
end

spec/requests/action_mailer_deliver_metrics_spec.rb

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,11 @@
1818

1919
expect_metric(
2020
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"
2823
),
2924
values: a_hash_including(
30-
additional_value: :value,
31-
request_id: :request_id,
32-
value: 1
25+
value: 1
3326
)
3427
)
3528
end

spec/requests/action_view_collection_metrics_spec.rb

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,12 @@
1818
expect_metric(
1919
name: "rails",
2020
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")
2823
),
2924
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)
3427
)
3528
)
3629
end
@@ -43,8 +36,7 @@
4336
expect_metric(
4437
name: "rails",
4538
tags: a_hash_including(
46-
location: "MetricsController#index",
47-
hook: "render_collection"
39+
hook: "render_collection"
4840
),
4941
timestamp: 1_514_797_200
5042
)
@@ -58,8 +50,7 @@
5850
expect_no_metric(
5951
name: "rails",
6052
tags: a_hash_including(
61-
location: "MetricsController#index",
62-
hook: "render_collection"
53+
hook: "render_collection"
6354
)
6455
)
6556
end

spec/requests/action_view_partial_metrics_spec.rb

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,11 @@
1717

1818
expect_metric(
1919
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")
2722
),
2823
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)
3225
)
3326
)
3427
end
@@ -40,8 +33,7 @@
4033

4134
expect_metric(
4235
tags: a_hash_including(
43-
location: "MetricsController#index",
44-
hook: "render_partial"
36+
hook: "render_partial"
4537
),
4638
timestamp: 1_514_797_200
4739
)
@@ -54,8 +46,7 @@
5446

5547
expect_no_metric(
5648
tags: a_hash_including(
57-
location: "MetricsController#index",
58-
hook: "render_partial"
49+
hook: "render_partial"
5950
)
6051
)
6152
end

spec/requests/action_view_template_metrics_spec.rb

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,11 @@
1717

1818
expect_metric(
1919
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")
2722
),
2823
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)
3225
)
3326
)
3427
end
@@ -40,8 +33,7 @@
4033

4134
expect_metric(
4235
tags: a_hash_including(
43-
location: "MetricsController#index",
44-
hook: "render_template"
36+
hook: "render_template"
4537
),
4638
timestamp: 1_514_797_200
4739
)
@@ -54,8 +46,7 @@
5446

5547
expect_no_metric(
5648
tags: a_hash_including(
57-
location: "MetricsController#index",
58-
hook: "render_template"
49+
hook: "render_template"
5950
)
6051
)
6152
end

spec/requests/active_job_enqueue_metrics_spec.rb

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,13 @@
1818

1919
expect_metric(
2020
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"
3025
),
3126
values: a_hash_including(
32-
additional_value: :value,
33-
request_id: :request_id,
34-
value: 1
27+
value: 1
3528
)
3629
)
3730
end
@@ -43,7 +36,6 @@
4336

4437
expect_metric(
4538
tags: a_hash_including(
46-
location: "MetricsController#index",
4739
hook: "enqueue"
4840
),
4941
timestamp: 1_514_797_200
@@ -57,7 +49,6 @@
5749

5850
expect_no_metric(
5951
tags: a_hash_including(
60-
location: "MetricsController#index",
6152
hook: "enqueue"
6253
)
6354
)

spec/requests/active_job_perform_metrics_spec.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@
2020

2121
expect_metric(
2222
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"
3127
),
3228
values: a_hash_including(
3329
value: be_between(0, 30)
@@ -44,7 +40,6 @@
4440

4541
expect_metric(
4642
tags: a_hash_including(
47-
location: "MetricsController#index",
4843
hook: "perform"
4944
),
5045
timestamp: 1_514_797_200
@@ -60,7 +55,6 @@
6055

6156
expect_no_metric(
6257
tags: a_hash_including(
63-
location: "MetricsController#index",
6458
hook: "perform"
6559
)
6660
)

spec/requests/active_record_instantiation_metrics_spec.rb

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,12 @@
1919

2020
expect_metric(
2121
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"
2924
),
3025
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
3528
)
3629
)
3730
end
@@ -43,8 +36,7 @@
4336

4437
expect_metric(
4538
tags: a_hash_including(
46-
location: "MetricsController#show",
47-
hook: "instantiation"
39+
hook: "instantiation"
4840
),
4941
timestamp: 1_514_797_200
5042
)
@@ -57,8 +49,7 @@
5749

5850
expect_no_metric(
5951
tags: a_hash_including(
60-
location: "MetricsController#show",
61-
hook: "instantiation"
52+
hook: "instantiation"
6253
)
6354
)
6455
end

spec/requests/active_record_sql_metrics_spec.rb

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,14 @@
1919

2020
expect_metric(
2121
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"
3126
),
3227
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)"
3730
)
3831
)
3932
end
@@ -45,21 +38,14 @@
4538

4639
expect_metric(
4740
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"
5745
),
5846
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)"
6349
)
6450
)
6551
end
@@ -71,7 +57,6 @@
7157

7258
expect_metric(
7359
tags: a_hash_including(
74-
location: "MetricsController#index",
7560
hook: "sql"
7661
),
7762
timestamp: 1_514_797_200
@@ -85,7 +70,6 @@
8570

8671
expect_no_metric(
8772
tags: a_hash_including(
88-
location: "MetricsController#index",
8973
hook: "sql"
9074
)
9175
)

0 commit comments

Comments
 (0)