inst_statsd 2.1.0 → 3.0.2
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/event.rb +64 -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 +13 -4
- data/lib/inst_statsd/version.rb +5 -0
- data/lib/inst_statsd.rb +5 -1
- 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/event_spec.rb +159 -0
- data/spec/inst_statsd/inst_statsd_spec.rb +4 -2
- 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 +30 -3
- data/spec/spec_helper.rb +2 -0
- data/test.sh +3 -3
- metadata +44 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52813306c6a3409e9abe7f114c58a471afe310eadd722bf555d0bd058144ce06
|
4
|
+
data.tar.gz: a899e4395f5cf3340040e500ad7ccdf4ac3f7c0fbcccbb52bb738f35e9f353a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e81e6b93a69826837fd5d952db4e9d784d3ae9230e72e9a62c6abb21dba6deb248a9baf89690e4d4bad4b0710bfd0dd72d93e5d8463f60c8265dbfbc42ea152c
|
7
|
+
data.tar.gz: 718e935a24b5e899c1bd67ea5669bcb0fada8e78a71c6e2b93b43f57b3744354fe732ebe702f2e06fb28ad8a325dbc3a319d99e58916aef593445a5d172607fb
|
data/lib/inst_statsd/counter.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module InstStatsd
|
4
|
+
# Mix-in methods for supporting DataDog events
|
5
|
+
# See https://docs.datadoghq.com/service_management/events/
|
6
|
+
module Event
|
7
|
+
SUPPORTED_TYPES = %i[
|
8
|
+
deploy
|
9
|
+
feature_disabled
|
10
|
+
feature_enabled
|
11
|
+
provision
|
12
|
+
refresh
|
13
|
+
].freeze
|
14
|
+
|
15
|
+
def instance; end
|
16
|
+
def data_dog?; end
|
17
|
+
def dog_tags; end
|
18
|
+
|
19
|
+
# This end point allows you to post events to the DatDog event stream.
|
20
|
+
#
|
21
|
+
# @param [String] title Event title
|
22
|
+
# @param [String] text Event text. Supports newlines (+\n+)
|
23
|
+
# @param [String, nil] :type Can be "deploy", "feature_disabled",
|
24
|
+
# "feature_enabled", "provision", or "refresh"
|
25
|
+
# @param [Hash] :tags tags to be added to event. Note that the
|
26
|
+
# environment, service, and other data are automatically
|
27
|
+
# added as tags for you without specifying them here.
|
28
|
+
# @param [Integer, String, nil] :date_happened (nil) Assign a timestamp
|
29
|
+
# to the event. Default is now when none
|
30
|
+
# @param [String, nil] :priority ('normal') Can be "normal" or "low"
|
31
|
+
# @param [String, nil] :alert_type ('info') Can be "error", "warning", "info" or "success".
|
32
|
+
#
|
33
|
+
# @example Report an event:
|
34
|
+
# InstStatsd::Statsd.event(
|
35
|
+
# "Quiz API Deploy",
|
36
|
+
# "<release> was deployed to Quiz API",
|
37
|
+
# tags: {foo: 'bar'},
|
38
|
+
# type: 'deploy',
|
39
|
+
# alert_type: :success
|
40
|
+
# )
|
41
|
+
def event(title, text, type: nil, tags: {}, alert_type: nil, priority: nil, date_happened: nil)
|
42
|
+
return unless instance && data_dog?
|
43
|
+
|
44
|
+
instance.event(
|
45
|
+
title,
|
46
|
+
text,
|
47
|
+
{
|
48
|
+
alert_type: alert_type,
|
49
|
+
priority: priority,
|
50
|
+
date_happened: date_happened,
|
51
|
+
tags: tags_from_opts(tags, type, dog_tags)
|
52
|
+
}.compact
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def tags_from_opts(tags, type, dd_tags)
|
59
|
+
custom_tags = tags.merge(dd_tags)
|
60
|
+
custom_tags[:type] = type if SUPPORTED_TYPES.include? type
|
61
|
+
custom_tags.compact
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -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
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Proxy class to communicate messages to statsd
|
2
4
|
# Available statsd messages are described in:
|
3
5
|
# https://github.com/etsy/statsd/blob/master/README.md
|
@@ -22,6 +24,8 @@
|
|
22
24
|
|
23
25
|
module InstStatsd
|
24
26
|
module Statsd
|
27
|
+
extend InstStatsd::Event
|
28
|
+
|
25
29
|
# replace "." in key names with another character to avoid creating spurious sub-folders in graphite
|
26
30
|
def self.escape(str, replacement = '_')
|
27
31
|
str.respond_to?(:gsub) ? str.gsub('.', replacement) : str
|
@@ -41,7 +45,7 @@ module InstStatsd
|
|
41
45
|
if self.instance
|
42
46
|
if Array === stat
|
43
47
|
stat.each do |st|
|
44
|
-
self.#{method}(st, *args, tags:
|
48
|
+
self.#{method}(st, *args, tags: tags, short_stat: nil)
|
45
49
|
end
|
46
50
|
return
|
47
51
|
end
|
@@ -53,11 +57,15 @@ module InstStatsd
|
|
53
57
|
end
|
54
58
|
|
55
59
|
if data_dog?
|
60
|
+
tags ||= {}
|
56
61
|
tags.merge!(dog_tags) if tags.is_a? Hash
|
57
62
|
tags = convert_tags(tags)
|
58
63
|
tags << 'host:' unless self.append_hostname?
|
59
64
|
short_stat ||= stat_name
|
60
|
-
|
65
|
+
opts = { tags: tags }
|
66
|
+
opts[:sample_rate] = args.pop if args.length == 2
|
67
|
+
args << opts
|
68
|
+
self.instance.#{method}(short_stat, *args)
|
61
69
|
else
|
62
70
|
self.instance.#{method}(stat_name, *args)
|
63
71
|
end
|
@@ -107,8 +115,9 @@ module InstStatsd
|
|
107
115
|
@data_dog = true
|
108
116
|
host = statsd_settings[:host] || 'localhost'
|
109
117
|
port = statsd_settings[:port] || 8125
|
110
|
-
|
111
|
-
@statsd
|
118
|
+
require 'datadog/statsd'
|
119
|
+
@statsd = ::Datadog::Statsd.new(host, port, namespace: statsd_settings[:namespace])
|
120
|
+
self.dog_tags.replace(statsd_settings[:dog_tags] || {})
|
112
121
|
@append_hostname = !statsd_settings.key?(:append_hostname) || !!statsd_settings[:append_hostname]
|
113
122
|
elsif statsd_settings && statsd_settings[:host]
|
114
123
|
@statsd = ::Statsd.new(statsd_settings[:host])
|
data/lib/inst_statsd.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'statsd'
|
2
4
|
|
3
5
|
module InstStatsd
|
@@ -6,6 +8,7 @@ module InstStatsd
|
|
6
8
|
|
7
9
|
class ConfigurationError < StandardError; end
|
8
10
|
|
11
|
+
require 'inst_statsd/event'
|
9
12
|
require 'inst_statsd/statsd'
|
10
13
|
require 'inst_statsd/block_stat'
|
11
14
|
require 'inst_statsd/block_tracking'
|
@@ -42,12 +45,13 @@ module InstStatsd
|
|
42
45
|
end
|
43
46
|
|
44
47
|
def env_settings(env = ENV)
|
48
|
+
dog_tags = JSON.parse(env['INST_DOG_TAGS']).to_h if env['INST_DOG_TAGS']
|
45
49
|
config = {
|
46
50
|
host: env.fetch('INST_STATSD_HOST', nil),
|
47
51
|
port: env.fetch('INST_STATSD_PORT', nil),
|
48
52
|
namespace: env.fetch('INST_STATSD_NAMESPACE', nil),
|
49
53
|
append_hostname: env.fetch('INST_STATSD_APPEND_HOSTNAME', nil),
|
50
|
-
dog_tags:
|
54
|
+
dog_tags: dog_tags
|
51
55
|
}
|
52
56
|
config.delete_if { |_k, v| v.nil? }
|
53
57
|
convert_bool(config, :append_hostname)
|
@@ -0,0 +1,159 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe InstStatsd::Event do
|
6
|
+
include described_class
|
7
|
+
|
8
|
+
let(:title) { "Title" }
|
9
|
+
let(:text) {"Some text."}
|
10
|
+
|
11
|
+
let(:instance) { double }
|
12
|
+
let(:data_dog?) { true }
|
13
|
+
let(:dog_tags) { {} }
|
14
|
+
let(:opts) { {} }
|
15
|
+
|
16
|
+
describe '#event' do
|
17
|
+
subject { event(title, text, opts) }
|
18
|
+
|
19
|
+
context 'with title and text only' do
|
20
|
+
let(:opts) { {} }
|
21
|
+
|
22
|
+
it 'invokes "event" on the instance with title and text' do
|
23
|
+
expect(instance).to receive(:event).with(
|
24
|
+
title,
|
25
|
+
text,
|
26
|
+
tags: {}
|
27
|
+
)
|
28
|
+
|
29
|
+
subject
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'with alert_type set' do
|
34
|
+
let(:opts) { { alert_type: :error } }
|
35
|
+
|
36
|
+
it 'invokes "event" on the instance with expected arguments' do
|
37
|
+
expect(instance).to receive(:event).with(
|
38
|
+
title,
|
39
|
+
text,
|
40
|
+
alert_type: :error,
|
41
|
+
tags: {}
|
42
|
+
)
|
43
|
+
|
44
|
+
subject
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'with priority set' do
|
49
|
+
let(:opts) { { priority: :low } }
|
50
|
+
|
51
|
+
it 'invokes "event" on the instance with expected arguments' do
|
52
|
+
expect(instance).to receive(:event).with(
|
53
|
+
title,
|
54
|
+
text,
|
55
|
+
priority: :low,
|
56
|
+
tags: {}
|
57
|
+
)
|
58
|
+
|
59
|
+
subject
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'with date_happened set' do
|
64
|
+
let(:opts) { { date_happened: date_happened } }
|
65
|
+
let(:date_happened) { Time.now.to_i }
|
66
|
+
|
67
|
+
it 'invokes "event" on the instance with expected arguments' do
|
68
|
+
expect(instance).to receive(:event).with(
|
69
|
+
title,
|
70
|
+
text,
|
71
|
+
date_happened: date_happened,
|
72
|
+
tags: {}
|
73
|
+
)
|
74
|
+
|
75
|
+
subject
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'with an invalid type set' do
|
80
|
+
let(:opts) { { type: :banana } }
|
81
|
+
|
82
|
+
it 'does not sent the invalid aggregation key' do
|
83
|
+
expect(instance).to receive(:event).with(
|
84
|
+
title,
|
85
|
+
text,
|
86
|
+
tags: {}
|
87
|
+
)
|
88
|
+
|
89
|
+
subject
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'with a valid type set' do
|
94
|
+
let(:opts) { { type: :deploy } }
|
95
|
+
|
96
|
+
it 'sets the valid aggregation key' do
|
97
|
+
expect(instance).to receive(:event).with(
|
98
|
+
title,
|
99
|
+
text,
|
100
|
+
tags: {type: :deploy}
|
101
|
+
)
|
102
|
+
|
103
|
+
subject
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'with custom tags' do
|
108
|
+
let(:opts) { { tags: { project: 'cool-project'} } }
|
109
|
+
|
110
|
+
it 'invokes "event" on the instance with expected arguments' do
|
111
|
+
expect(instance).to receive(:event).with(
|
112
|
+
title,
|
113
|
+
text,
|
114
|
+
tags: { project: 'cool-project' }
|
115
|
+
)
|
116
|
+
|
117
|
+
subject
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'with all opts set' do
|
122
|
+
let(:date_happened) { Time.now.to_i }
|
123
|
+
let(:opts) do
|
124
|
+
{
|
125
|
+
type: :deploy,
|
126
|
+
alert_type: :warning,
|
127
|
+
priority: :low,
|
128
|
+
date_happened: date_happened,
|
129
|
+
tags: { foo: 'bar' }
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'sets all arguments' do
|
134
|
+
expect(instance).to receive(:event).with(
|
135
|
+
title,
|
136
|
+
text,
|
137
|
+
alert_type: :warning,
|
138
|
+
priority: :low,
|
139
|
+
date_happened: date_happened,
|
140
|
+
tags: { foo: 'bar', type: :deploy }
|
141
|
+
)
|
142
|
+
|
143
|
+
subject
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'when the instance is not DataDog' do
|
148
|
+
let(:data_dog?) { false }
|
149
|
+
|
150
|
+
it { is_expected.to eq nil }
|
151
|
+
|
152
|
+
it 'does not invoke "event" on the instance' do
|
153
|
+
expect(instance).not_to receive(:event)
|
154
|
+
|
155
|
+
subject
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe InstStatsd do
|
@@ -121,10 +123,10 @@ describe InstStatsd do
|
|
121
123
|
|
122
124
|
it 'builds settings hash with dog environment vars' do
|
123
125
|
env = {
|
124
|
-
'INST_DOG_TAGS' => {app:
|
126
|
+
'INST_DOG_TAGS' => '{"app": "canvas", "env": "prod"}',
|
125
127
|
}
|
126
128
|
expected = {
|
127
|
-
dog_tags: {app
|
129
|
+
dog_tags: {"app" => "canvas", "env" => "prod"},
|
128
130
|
}
|
129
131
|
expect(InstStatsd.env_settings(env)).to eq(expected)
|
130
132
|
end
|
@@ -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
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe InstStatsd::Statsd do
|
@@ -8,6 +10,10 @@ describe InstStatsd::Statsd do
|
|
8
10
|
InstStatsd::Statsd.reset_instance
|
9
11
|
end
|
10
12
|
|
13
|
+
it 'includes the events module' do
|
14
|
+
expect(described_class).to respond_to :event
|
15
|
+
end
|
16
|
+
|
11
17
|
it 'appends the hostname to stat names by default' do
|
12
18
|
allow(InstStatsd::Statsd).to receive(:hostname).and_return('testhost')
|
13
19
|
statsd = double
|
@@ -24,8 +30,11 @@ describe InstStatsd::Statsd do
|
|
24
30
|
it 'sending tags should not break statsd' do
|
25
31
|
default_tags = {app: 'canvas', env: 'prod'}
|
26
32
|
short_stat = 'test2'
|
33
|
+
env = {
|
34
|
+
'INST_DOG_TAGS' => '{"app": "canvas", "env": "prod"}',
|
35
|
+
}
|
36
|
+
InstStatsd.env_settings(env)
|
27
37
|
allow(InstStatsd::Statsd).to receive(:hostname).and_return('testhost')
|
28
|
-
allow(InstStatsd::Statsd).to receive(:dog_tags).and_return(default_tags)
|
29
38
|
allow(InstStatsd::Statsd).to receive(:short_stat).and_return(short_stat)
|
30
39
|
statsd = double
|
31
40
|
allow(InstStatsd::Statsd).to receive(:instance).and_return(statsd)
|
@@ -53,7 +62,7 @@ describe InstStatsd::Statsd do
|
|
53
62
|
expect(statsd).to receive(method).with(short_stat, 'test', tags: converted_tags)
|
54
63
|
InstStatsd::Statsd.send(method, 'test.name', 'test', short_stat: short_stat)
|
55
64
|
end
|
56
|
-
expect(statsd).to receive('timing').with(short_stat, anything, anything, tags: converted_tags)
|
65
|
+
expect(statsd).to receive('timing').with(short_stat, anything, sample_rate: anything, tags: converted_tags)
|
57
66
|
expect(InstStatsd::Statsd.time('test.name', short_stat: short_stat) {'test'}).to eq 'test'
|
58
67
|
end
|
59
68
|
|
@@ -69,7 +78,7 @@ describe InstStatsd::Statsd do
|
|
69
78
|
expect(statsd).to receive(method).with('test.name', 'test', tags: converted_tags)
|
70
79
|
InstStatsd::Statsd.send(method, 'test.name', 'test')
|
71
80
|
end
|
72
|
-
expect(statsd).to receive('timing').with('test.name', anything, anything, tags: converted_tags)
|
81
|
+
expect(statsd).to receive('timing').with('test.name', anything, sample_rate: anything, tags: converted_tags)
|
73
82
|
expect(InstStatsd::Statsd.time('test.name') {'test'}).to eq 'test'
|
74
83
|
end
|
75
84
|
|
@@ -86,6 +95,24 @@ describe InstStatsd::Statsd do
|
|
86
95
|
expect(InstStatsd::Statsd.time('test.name') { 'test' }).to eq 'test'
|
87
96
|
end
|
88
97
|
|
98
|
+
context 'with datadog enabled' do
|
99
|
+
it 'handles being called with an array of stat names' do
|
100
|
+
converted_tags = %w[tag:value host:]
|
101
|
+
statsd = double
|
102
|
+
allow(InstStatsd::Statsd).to receive(:instance).and_return(statsd)
|
103
|
+
allow(InstStatsd::Statsd).to receive(:append_hostname?).and_return(false)
|
104
|
+
allow(InstStatsd::Statsd).to receive(:data_dog?).and_return(true)
|
105
|
+
METHODS.each do |method|
|
106
|
+
expect(statsd).to receive(method).once.with('test.one', 'value', tags: converted_tags)
|
107
|
+
expect(statsd).to receive(method).once.with('test.two', 'value', tags: converted_tags)
|
108
|
+
InstStatsd::Statsd.send(method, %w[test.one test.two], 'value', tags: {tag: 'value'}, short_stat: 'short_stat')
|
109
|
+
end
|
110
|
+
expect(statsd).to receive('timing').once.with('test.one', anything, tags: converted_tags, sample_rate: anything)
|
111
|
+
expect(statsd).to receive('timing').once.with('test.two', anything, tags: converted_tags, sample_rate: anything)
|
112
|
+
expect(InstStatsd::Statsd.time(%w[test.one test.two], tags: {tag: 'value'}, short_stat: 'short_stat') { 'test' }).to eq 'test'
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
89
116
|
it "ignores all calls if statsd isn't enabled" do
|
90
117
|
allow(InstStatsd::Statsd).to receive(:instance).and_return(nil)
|
91
118
|
METHODS.each do |method|
|
data/spec/spec_helper.rb
CHANGED
data/test.sh
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
result=0
|
3
3
|
|
4
4
|
echo "################ inst_statsd ################"
|
5
|
-
echo "################ Running tests
|
6
|
-
bundle
|
7
|
-
bundle exec rspec spec
|
5
|
+
echo "################ Running tests ################"
|
6
|
+
bundle exec appraisal install
|
7
|
+
bundle exec appraisal rspec spec
|
8
8
|
let result=$result+$?
|
9
9
|
|
10
10
|
if [ $result -eq 0 ]; then
|
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:
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Cloward
|
@@ -9,22 +9,34 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-08-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dogstatsd-ruby
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '4.2'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '6.0'
|
24
|
+
- - "!="
|
19
25
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
26
|
+
version: 5.0.0
|
21
27
|
type: :runtime
|
22
28
|
prerelease: false
|
23
29
|
version_requirements: !ruby/object:Gem::Requirement
|
24
30
|
requirements:
|
25
|
-
- - "
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.2'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '6.0'
|
37
|
+
- - "!="
|
26
38
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
39
|
+
version: 5.0.0
|
28
40
|
- !ruby/object:Gem::Dependency
|
29
41
|
name: statsd-ruby
|
30
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,28 +55,42 @@ dependencies:
|
|
43
55
|
name: aroi
|
44
56
|
requirement: !ruby/object:Gem::Requirement
|
45
57
|
requirements:
|
46
|
-
- - "
|
58
|
+
- - ">="
|
47
59
|
- !ruby/object:Gem::Version
|
48
|
-
version: 0.0.
|
60
|
+
version: 0.0.7
|
49
61
|
type: :runtime
|
50
62
|
prerelease: false
|
51
63
|
version_requirements: !ruby/object:Gem::Requirement
|
52
64
|
requirements:
|
53
|
-
- - "
|
65
|
+
- - ">="
|
54
66
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.0.
|
67
|
+
version: 0.0.7
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: appraisal
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
56
82
|
- !ruby/object:Gem::Dependency
|
57
83
|
name: bundler
|
58
84
|
requirement: !ruby/object:Gem::Requirement
|
59
85
|
requirements:
|
60
|
-
- - "
|
86
|
+
- - ">="
|
61
87
|
- !ruby/object:Gem::Version
|
62
88
|
version: '1.5'
|
63
89
|
type: :development
|
64
90
|
prerelease: false
|
65
91
|
version_requirements: !ruby/object:Gem::Requirement
|
66
92
|
requirements:
|
67
|
-
- - "
|
93
|
+
- - ">="
|
68
94
|
- !ruby/object:Gem::Version
|
69
95
|
version: '1.5'
|
70
96
|
- !ruby/object:Gem::Dependency
|
@@ -122,15 +148,18 @@ files:
|
|
122
148
|
- lib/inst_statsd/block_tracking.rb
|
123
149
|
- lib/inst_statsd/counter.rb
|
124
150
|
- lib/inst_statsd/default_tracking.rb
|
151
|
+
- lib/inst_statsd/event.rb
|
125
152
|
- lib/inst_statsd/null_logger.rb
|
126
153
|
- lib/inst_statsd/request_logger.rb
|
127
154
|
- lib/inst_statsd/request_stat.rb
|
128
155
|
- lib/inst_statsd/request_tracking.rb
|
129
156
|
- lib/inst_statsd/sql_tracker.rb
|
130
157
|
- lib/inst_statsd/statsd.rb
|
158
|
+
- lib/inst_statsd/version.rb
|
131
159
|
- spec/inst_statsd/block_stat_spec.rb
|
132
160
|
- spec/inst_statsd/block_tracking_spec.rb
|
133
161
|
- spec/inst_statsd/counter_spec.rb
|
162
|
+
- spec/inst_statsd/event_spec.rb
|
134
163
|
- spec/inst_statsd/inst_statsd_spec.rb
|
135
164
|
- spec/inst_statsd/null_logger_spec.rb
|
136
165
|
- spec/inst_statsd/request_logger_spec.rb
|
@@ -153,15 +182,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
153
182
|
requirements:
|
154
183
|
- - ">="
|
155
184
|
- !ruby/object:Gem::Version
|
156
|
-
version: '2.
|
185
|
+
version: '2.7'
|
157
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
187
|
requirements:
|
159
188
|
- - ">="
|
160
189
|
- !ruby/object:Gem::Version
|
161
190
|
version: '0'
|
162
191
|
requirements: []
|
163
|
-
|
164
|
-
rubygems_version: 2.7.6
|
192
|
+
rubygems_version: 3.2.6
|
165
193
|
signing_key:
|
166
194
|
specification_version: 4
|
167
195
|
summary: Statsd for Instructure
|
@@ -169,6 +197,7 @@ test_files:
|
|
169
197
|
- spec/inst_statsd/block_stat_spec.rb
|
170
198
|
- spec/inst_statsd/block_tracking_spec.rb
|
171
199
|
- spec/inst_statsd/counter_spec.rb
|
200
|
+
- spec/inst_statsd/event_spec.rb
|
172
201
|
- spec/inst_statsd/inst_statsd_spec.rb
|
173
202
|
- spec/inst_statsd/null_logger_spec.rb
|
174
203
|
- spec/inst_statsd/request_logger_spec.rb
|