inst_statsd 2.1.6 → 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/block_stat.rb +2 -0
- data/lib/inst_statsd/block_tracking.rb +2 -0
- data/lib/inst_statsd/counter.rb +2 -0
- data/lib/inst_statsd/default_tracking.rb +2 -0
- data/lib/inst_statsd/null_logger.rb +2 -0
- data/lib/inst_statsd/request_logger.rb +2 -0
- data/lib/inst_statsd/request_stat.rb +14 -0
- data/lib/inst_statsd/request_tracking.rb +2 -0
- data/lib/inst_statsd/sql_tracker.rb +2 -0
- data/lib/inst_statsd/statsd.rb +2 -0
- data/lib/inst_statsd.rb +2 -0
- data/spec/inst_statsd/block_stat_spec.rb +2 -0
- data/spec/inst_statsd/block_tracking_spec.rb +2 -0
- data/spec/inst_statsd/counter_spec.rb +2 -0
- data/spec/inst_statsd/inst_statsd_spec.rb +2 -0
- data/spec/inst_statsd/null_logger_spec.rb +2 -0
- data/spec/inst_statsd/request_logger_spec.rb +2 -0
- data/spec/inst_statsd/request_stat_spec.rb +21 -2
- data/spec/inst_statsd/request_tracking_spec.rb +2 -0
- data/spec/inst_statsd/sql_tracker_spec.rb +2 -0
- data/spec/inst_statsd/statsd_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- metadata +5 -6
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
|
data/lib/inst_statsd/counter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module InstStatsd
|
2
4
|
class RequestStat < BlockStat
|
3
5
|
def initialize(name, start, finish, id, payload, statsd=InstStatsd::Statsd)
|
@@ -18,6 +20,7 @@ module InstStatsd
|
|
18
20
|
self.short_stat = "request"
|
19
21
|
self.tags[:controller] = controller if controller
|
20
22
|
self.tags[:action] = action if action
|
23
|
+
self.tags[:status] = status if status
|
21
24
|
else
|
22
25
|
self.common_key = "request.#{controller}.#{action}" if controller && action
|
23
26
|
end
|
@@ -46,6 +49,17 @@ module InstStatsd
|
|
46
49
|
@payload.fetch(:params, {})['action']
|
47
50
|
end
|
48
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
|
+
|
49
63
|
def total
|
50
64
|
if (!@finish || !@start)
|
51
65
|
return 0
|
data/lib/inst_statsd/statsd.rb
CHANGED
data/lib/inst_statsd.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
|
@@ -68,6 +70,22 @@ describe InstStatsd::RequestStat do
|
|
68
70
|
end
|
69
71
|
end
|
70
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
|
+
|
71
89
|
describe '#total' do
|
72
90
|
it 'correctly calculates milliseconds from start, finish' do
|
73
91
|
rs = create_subject({params: {}})
|
@@ -111,10 +129,11 @@ describe InstStatsd::RequestStat do
|
|
111
129
|
params: {
|
112
130
|
'controller' => 'foo',
|
113
131
|
'action' => 'index'
|
114
|
-
}
|
132
|
+
},
|
133
|
+
status: 200
|
115
134
|
}
|
116
135
|
rs = create_subject(payload, statsd)
|
117
|
-
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'}} )
|
118
137
|
rs.report
|
119
138
|
end
|
120
139
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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
|
@@ -9,7 +9,7 @@ authors:
|
|
9
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
|
@@ -43,14 +43,14 @@ dependencies:
|
|
43
43
|
name: aroi
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 0.0.7
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 0.0.7
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -174,8 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
- !ruby/object:Gem::Version
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
|
-
|
178
|
-
rubygems_version: 2.7.6
|
177
|
+
rubygems_version: 3.0.3
|
179
178
|
signing_key:
|
180
179
|
specification_version: 4
|
181
180
|
summary: Statsd for Instructure
|