inst_statsd 3.2.0 → 3.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/distribution.rb +3 -0
- data/lib/inst_statsd/version.rb +1 -1
- data/spec/inst_statsd/distribution_spec.rb +19 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70725525a856b43a9d37075d6bdf74fdeac3a7c3a306545bca25e41e3011ca9a
|
4
|
+
data.tar.gz: e7fcf1593bf7186c877be71fbd38f86c285fa852294ee08e00d90049076cb0b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '02963b466ff709d44a2e7ed69f8a060263d0a66b87cf856d1bf9a8f75814441dda10692fb7184096c36e7365865e94d2d322cc2a04863fe66183a21e97085e0e'
|
7
|
+
data.tar.gz: f24f390b747d2a86e81a45bde5e9160e86375dd565798da7e9bd037977b6be4cc71c4c29621fe3c87bade029c2884ee74b02382f2a100770563811edd3171ac8
|
@@ -29,6 +29,9 @@ module InstStatsd
|
|
29
29
|
# @example Increment the error count:
|
30
30
|
# InstStatsd::Statsd.distributed_increment('client.request.failed', tags: { status: '500' })
|
31
31
|
def distributed_increment(metric, tags: {})
|
32
|
+
# Non-Datadog clients don't support distribution metrics, so we use fall back to increment
|
33
|
+
return increment(metric, tags: tags) if instance && !data_dog?
|
34
|
+
|
32
35
|
distribution(metric, 1, tags: tags)
|
33
36
|
end
|
34
37
|
end
|
data/lib/inst_statsd/version.rb
CHANGED
@@ -4,19 +4,19 @@ require "spec_helper"
|
|
4
4
|
require "datadog/statsd"
|
5
5
|
|
6
6
|
RSpec.describe InstStatsd::Distribution do
|
7
|
+
let(:instance) { instance_double(Datadog::Statsd) }
|
8
|
+
|
9
|
+
before do
|
10
|
+
allow(InstStatsd::Statsd).to receive_messages(data_dog?: is_datadog, dog_tags: dog_tags, instance: instance)
|
11
|
+
end
|
12
|
+
|
7
13
|
describe ".distribution" do
|
8
14
|
subject { InstStatsd::Statsd.distribution(metric, value, tags: tags) }
|
9
15
|
|
10
|
-
let(:instance) { instance_double(Datadog::Statsd) }
|
11
|
-
|
12
16
|
let(:metric) { "client.request.failed" }
|
13
17
|
let(:value) { 23 }
|
14
18
|
let(:tags) { { status: "500" } }
|
15
19
|
|
16
|
-
before do
|
17
|
-
allow(InstStatsd::Statsd).to receive_messages(data_dog?: is_datadog, dog_tags: dog_tags, instance: instance)
|
18
|
-
end
|
19
|
-
|
20
20
|
context "when instance and data_dog? are configured" do
|
21
21
|
let(:dog_tags) { { environment: "production" } }
|
22
22
|
let(:is_datadog) { true }
|
@@ -49,6 +49,8 @@ RSpec.describe InstStatsd::Distribution do
|
|
49
49
|
|
50
50
|
let(:metric) { "client.request.failed" }
|
51
51
|
let(:tags) { { status: "500" } }
|
52
|
+
let(:dog_tags) { { status: "401" } }
|
53
|
+
let(:is_datadog) { true }
|
52
54
|
|
53
55
|
before do
|
54
56
|
allow(InstStatsd::Statsd).to receive_messages(distribution: nil)
|
@@ -59,5 +61,16 @@ RSpec.describe InstStatsd::Distribution do
|
|
59
61
|
|
60
62
|
subject
|
61
63
|
end
|
64
|
+
|
65
|
+
context "when the configured instance is not a DataDog instance" do
|
66
|
+
let(:dog_tags) { {} }
|
67
|
+
let(:is_datadog) { false }
|
68
|
+
|
69
|
+
it 'invokes "increment" on InstStatsd::Statsd with metric and tags' do
|
70
|
+
expect(InstStatsd::Statsd).to receive(:increment).with(metric, tags: tags)
|
71
|
+
|
72
|
+
subject
|
73
|
+
end
|
74
|
+
end
|
62
75
|
end
|
63
76
|
end
|