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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 705acd8e1a6b843e6f4e54ec0e1525f1165022547c22649d4b0c60c2c1fc83fa
4
- data.tar.gz: 1d0daad7330f761a6ea4642bd52c85a0a4bf5a6856e7bd967750670a7f08832e
3
+ metadata.gz: 70725525a856b43a9d37075d6bdf74fdeac3a7c3a306545bca25e41e3011ca9a
4
+ data.tar.gz: e7fcf1593bf7186c877be71fbd38f86c285fa852294ee08e00d90049076cb0b6
5
5
  SHA512:
6
- metadata.gz: 1a23712f36838b2fd9afd2fe15430c9239e14b212aa6a05ed3358c81ff9799a2d11345dc1170915de903d6a73eed0a0dce05c183c75661693296ab5511b2cdb8
7
- data.tar.gz: d5a2406ba15f33196527a9d24cb7d52d6eb5d0aea387f7a80d9382e389777e0c375473d50282af0841f9832adc8f27d8c89b3f07c249764de3170aa8b033303e
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InstStatsd
4
- VERSION = "3.2.0"
4
+ VERSION = "3.3.0"
5
5
  end
@@ -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
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: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Cloward