inst_statsd 3.3.0 → 3.3.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/distribution.rb +12 -4
- data/lib/inst_statsd/version.rb +1 -1
- data/spec/inst_statsd/distribution_spec.rb +10 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b97f7ba19c16e12f36248b86629b16fb1bc2216ba0da3c3ff1da012c08582ee2
|
4
|
+
data.tar.gz: d7f43c64a477c5e6bf733ede3185b54a692e26440e1ba340886ac6c524f9da5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
data/lib/inst_statsd/version.rb
CHANGED
@@ -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.
|
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:
|
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:
|
83
|
+
name: debug
|
84
84
|
requirement: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - ">="
|