inst_statsd 3.3.0 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70725525a856b43a9d37075d6bdf74fdeac3a7c3a306545bca25e41e3011ca9a
4
- data.tar.gz: e7fcf1593bf7186c877be71fbd38f86c285fa852294ee08e00d90049076cb0b6
3
+ metadata.gz: b97f7ba19c16e12f36248b86629b16fb1bc2216ba0da3c3ff1da012c08582ee2
4
+ data.tar.gz: d7f43c64a477c5e6bf733ede3185b54a692e26440e1ba340886ac6c524f9da5d
5
5
  SHA512:
6
- metadata.gz: '02963b466ff709d44a2e7ed69f8a060263d0a66b87cf856d1bf9a8f75814441dda10692fb7184096c36e7365865e94d2d322cc2a04863fe66183a21e97085e0e'
7
- data.tar.gz: f24f390b747d2a86e81a45bde5e9160e86375dd565798da7e9bd037977b6be4cc71c4c29621fe3c87bade029c2884ee74b02382f2a100770563811edd3171ac8
6
+ metadata.gz: 825783ba4ef42ff8abc7b97d3a8a387be9c93c30e9b746482c119a905c74de57341ab38d32723bb37e2d28d5b5cbc33bde84e531eaa04067138d96b7b8f1b492
7
+ data.tar.gz: 45a3cfbc0e101a1dfdc758155290dbfca30f1c89832b73a6e376010ba8aaecdea55ebca764c023adfbdd4150bf120ca0f2e82eda6ba631d245cead49a25b9850
@@ -18,21 +18,29 @@ module InstStatsd
18
18
  def distribution(metric, value, tags: {})
19
19
  return unless instance && data_dog?
20
20
 
21
- instance.distribution(metric, value, { tags: tags.merge(dog_tags) }.compact)
21
+ metric = if append_hostname?
22
+ "#{metric}.#{hostname}"
23
+ else
24
+ metric.to_s
25
+ end
26
+ tags = tags.merge(dog_tags) if tags.is_a?(Hash)
27
+
28
+ instance.distribution(metric, value, { tags: tags })
22
29
  end
23
30
 
24
31
  # Increments the specified distribution metric by 1.
25
32
  #
26
33
  # @param metric [String] The name of the metric to increment.
27
34
  # @param tags [Hash] Optional tags to associate with the metric.
35
+ # @param short_stat [String, nil] Stat name to use instead of `metric` if backed by DataDog.
28
36
  #
29
37
  # @example Increment the error count:
30
38
  # InstStatsd::Statsd.distributed_increment('client.request.failed', tags: { status: '500' })
31
- def distributed_increment(metric, tags: {})
39
+ def distributed_increment(metric, tags: {}, short_stat: nil)
32
40
  # 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?
41
+ return increment(metric, tags: tags, short_stat: short_stat) if instance && !data_dog?
34
42
 
35
- distribution(metric, 1, tags: tags)
43
+ distribution(short_stat || metric, 1, tags: tags)
36
44
  end
37
45
  end
38
46
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InstStatsd
4
- VERSION = "3.3.0"
4
+ VERSION = "3.3.2"
5
5
  end
@@ -30,6 +30,15 @@ RSpec.describe InstStatsd::Distribution do
30
30
 
31
31
  subject
32
32
  end
33
+
34
+ it "handles an array of tags" do
35
+ expect(instance).to receive(:distribution).with(
36
+ metric,
37
+ value,
38
+ { tags: ["status:500"] }
39
+ )
40
+ InstStatsd::Statsd.distribution(metric, value, tags: ["status:500"])
41
+ end
33
42
  end
34
43
 
35
44
  context "when instance and data_dog? are not configured" do
@@ -67,7 +76,7 @@ RSpec.describe InstStatsd::Distribution do
67
76
  let(:is_datadog) { false }
68
77
 
69
78
  it 'invokes "increment" on InstStatsd::Statsd with metric and tags' do
70
- expect(InstStatsd::Statsd).to receive(:increment).with(metric, tags: tags)
79
+ expect(InstStatsd::Statsd).to receive(:increment).with(metric, tags: tags, short_stat: nil)
71
80
 
72
81
  subject
73
82
  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.3.0
4
+ version: 3.3.2
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: 2024-12-09 00:00:00.000000000 Z
12
+ date: 2025-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aroi
@@ -80,7 +80,7 @@ dependencies:
80
80
  - !ruby/object:Gem::Version
81
81
  version: '1.5'
82
82
  - !ruby/object:Gem::Dependency
83
- name: byebug
83
+ name: debug
84
84
  requirement: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="