inst_statsd 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inst_statsd/request_stat.rb +12 -0
- data/spec/inst_statsd/request_stat_spec.rb +19 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 568ce7b0b1164ceb930ba4c27604d3600f3afc9faf9486fa55ed315c3e1b6e90
|
4
|
+
data.tar.gz: e8970517048f627c0449ba8fa241adaae49b9aa37b3a4faa5047aa64e67f07d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92c65a63134c03d227481e0fca2cf23e438268dd8fa59a124ac95795c7e3ec304ac6d7052d7e9e0270cdfdb89ff7bba24543b4021fdfed3dc098fedb6951364a
|
7
|
+
data.tar.gz: 53087ac5aa2d2efe2af74d037ed18a0723774b38e17e3ddb34a8de2b5f67ec74620ef33c02737f3393a1faaf48c81ff5cd0cbfb217f408eb57b249f97ed312d4
|
@@ -20,6 +20,7 @@ module InstStatsd
|
|
20
20
|
self.short_stat = "request"
|
21
21
|
self.tags[:controller] = controller if controller
|
22
22
|
self.tags[:action] = action if action
|
23
|
+
self.tags[:status] = status if status
|
23
24
|
else
|
24
25
|
self.common_key = "request.#{controller}.#{action}" if controller && action
|
25
26
|
end
|
@@ -48,6 +49,17 @@ module InstStatsd
|
|
48
49
|
@payload.fetch(:params, {})['action']
|
49
50
|
end
|
50
51
|
|
52
|
+
def status
|
53
|
+
status = @payload.fetch(:status, 0)
|
54
|
+
# Only return status group to reduce the number of indexed custom metrics (and cost) of datadog
|
55
|
+
return '1XX' if status >= 100 and status < 200
|
56
|
+
return '2XX' if status >= 200 and status < 300
|
57
|
+
return '3XX' if status >= 300 and status < 400
|
58
|
+
return '4XX' if status >= 400 and status < 500
|
59
|
+
return '5XX' if status >= 500 and status < 600
|
60
|
+
nil
|
61
|
+
end
|
62
|
+
|
51
63
|
def total
|
52
64
|
if (!@finish || !@start)
|
53
65
|
return 0
|
@@ -70,6 +70,22 @@ describe InstStatsd::RequestStat do
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
describe '#status' do
|
74
|
+
it 'should return nil if status is not defined' do
|
75
|
+
rs = create_subject
|
76
|
+
expect(rs.status).to eq nil
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should return HTTP status group if present' do
|
80
|
+
expect(create_subject({status: 200}).status).to eq '2XX'
|
81
|
+
expect(create_subject({status: 201}).status).to eq '2XX'
|
82
|
+
expect(create_subject({status: 302}).status).to eq '3XX'
|
83
|
+
expect(create_subject({status: 400}).status).to eq '4XX'
|
84
|
+
expect(create_subject({status: 404}).status).to eq '4XX'
|
85
|
+
expect(create_subject({status: 503}).status).to eq '5XX'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
73
89
|
describe '#total' do
|
74
90
|
it 'correctly calculates milliseconds from start, finish' do
|
75
91
|
rs = create_subject({params: {}})
|
@@ -113,10 +129,11 @@ describe InstStatsd::RequestStat do
|
|
113
129
|
params: {
|
114
130
|
'controller' => 'foo',
|
115
131
|
'action' => 'index'
|
116
|
-
}
|
132
|
+
},
|
133
|
+
status: 200
|
117
134
|
}
|
118
135
|
rs = create_subject(payload, statsd)
|
119
|
-
expect(statsd).to receive(:timing).with('request.total', 1000, {short_stat: 'request.total', tags: {action: "index", controller: "foo"}} )
|
136
|
+
expect(statsd).to receive(:timing).with('request.total', 1000, {short_stat: 'request.total', tags: {action: "index", controller: "foo", status: '2XX'}} )
|
120
137
|
rs.report
|
121
138
|
end
|
122
139
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inst_statsd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Cloward
|
8
8
|
- Jason Madsen
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-07-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dogstatsd-ruby
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
|
-
description:
|
126
|
+
description:
|
127
127
|
email:
|
128
128
|
- ncloward@instructure.com
|
129
129
|
- jmadsen@instructure.com
|
@@ -159,7 +159,7 @@ homepage: https://github.com/instructure/inst_statsd
|
|
159
159
|
licenses:
|
160
160
|
- MIT
|
161
161
|
metadata: {}
|
162
|
-
post_install_message:
|
162
|
+
post_install_message:
|
163
163
|
rdoc_options: []
|
164
164
|
require_paths:
|
165
165
|
- lib
|
@@ -174,8 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
- !ruby/object:Gem::Version
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
|
-
rubygems_version: 3.
|
178
|
-
signing_key:
|
177
|
+
rubygems_version: 3.0.3
|
178
|
+
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: Statsd for Instructure
|
181
181
|
test_files:
|