statsd-instrument 2.0.6 → 2.0.7
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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +4 -4
- data/CHANGELOG.md +2 -3
- data/README.md +1 -1
- data/lib/statsd/instrument/metric.rb +2 -5
- data/lib/statsd/instrument/version.rb +1 -1
- data/statsd-instrument.gemspec +1 -0
- data/test/benchmark/tags.rb +34 -0
- data/test/metric_test.rb +5 -7
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 332aeb4ca9870d03b48fae2f8322f81396e0a70b
|
4
|
+
data.tar.gz: aabec4e189d0e494b77be52fe604a43548b8f4c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2f06ab8c82e1bfc4f2dfcedc9984d05ec7797e125da782dbca2fe4c60ba2948ec2920e8f3fcdee61e660568f6e2ab961b7694be7f29092f7c29a46d5925f30b
|
7
|
+
data.tar.gz: 9d1e015f071f34af4ca7294269ce923b05222e1297ed798adec1c8d080310fc878e76ece7c7a50dd2a5bf2366d421b4f0d07f437c7a3f38d8c2885e5bf8501a3
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -102,10 +102,7 @@ class StatsD::Instrument::Metric
|
|
102
102
|
# @return [Array<String>, nil] the list of tags in canonical form.
|
103
103
|
def self.normalize_tags(tags)
|
104
104
|
return if tags.nil?
|
105
|
-
tags = tags.map { |k, v| "#{k}:#{v}" } if tags.is_a?(Hash)
|
106
|
-
tags.map
|
107
|
-
components = tag.split(':', 2)
|
108
|
-
components.map { |c| c.gsub(/[^\w\.-]+/, '_') }.join(':')
|
109
|
-
end
|
105
|
+
tags = tags.map { |k, v| "#{k.to_s.tr(':', '')}:#{v.to_s.tr(':', '')}" } if tags.is_a?(Hash)
|
106
|
+
tags.map { |tag| tag.tr('|,'.freeze, ''.freeze) }
|
110
107
|
end
|
111
108
|
end
|
data/statsd-instrument.gemspec
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'statsd-instrument'
|
2
|
+
require 'benchmark/ips'
|
3
|
+
|
4
|
+
Benchmark.ips do |bench|
|
5
|
+
bench.report("normalized tags with simple hash") do
|
6
|
+
StatsD::Instrument::Metric.normalize_tags(:tag => 'value')
|
7
|
+
end
|
8
|
+
|
9
|
+
bench.report("normalized tags with simple array") do
|
10
|
+
StatsD::Instrument::Metric.normalize_tags(['test:test'])
|
11
|
+
end
|
12
|
+
|
13
|
+
bench.report("normalized tags with large hash") do
|
14
|
+
StatsD::Instrument::Metric.normalize_tags({
|
15
|
+
mobile: true,
|
16
|
+
pod: "1",
|
17
|
+
protocol: "https",
|
18
|
+
country: "Langbortistan",
|
19
|
+
complete: true,
|
20
|
+
shop: "omg shop that has a longer name",
|
21
|
+
})
|
22
|
+
end
|
23
|
+
|
24
|
+
bench.report("normalized tags with large array") do
|
25
|
+
StatsD::Instrument::Metric.normalize_tags([
|
26
|
+
"mobile:true",
|
27
|
+
"pod:1",
|
28
|
+
"protocol:https",
|
29
|
+
"country:Langbortistan",
|
30
|
+
"complete:true",
|
31
|
+
"shop:omg_shop_that_has_a_longer_name",
|
32
|
+
])
|
33
|
+
end
|
34
|
+
end
|
data/test/metric_test.rb
CHANGED
@@ -24,15 +24,13 @@ class MetricTest < Minitest::Test
|
|
24
24
|
assert_equal 'counter', m.name
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
assert_equal ['
|
29
|
-
assert_equal ['
|
30
|
-
assert_equal ['test:test_test'], StatsD::Instrument::Metric.normalize_tags(['test:test:test'])
|
31
|
-
assert_equal ['topic:foo_foo', 'bar_'], StatsD::Instrument::Metric.normalize_tags(['topic:foo : foo', 'bar '])
|
27
|
+
def test_handle_bad_tags
|
28
|
+
assert_equal ['ignored'], StatsD::Instrument::Metric.normalize_tags(['igno|red'])
|
29
|
+
assert_equal ['lolclass:omglol'], StatsD::Instrument::Metric.normalize_tags({ :"lol::class" => "omg::lol" })
|
32
30
|
end
|
33
|
-
|
31
|
+
|
34
32
|
def test_rewrite_tags_provided_as_hash
|
35
33
|
assert_equal ['tag:value'], StatsD::Instrument::Metric.normalize_tags(:tag => 'value')
|
36
34
|
assert_equal ['tag:value', 'tag2:value2'], StatsD::Instrument::Metric.normalize_tags(:tag => 'value', :tag2 => 'value2')
|
37
35
|
end
|
38
|
-
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statsd-instrument
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Storimer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-05-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -68,6 +68,20 @@ dependencies:
|
|
68
68
|
- - '>='
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: benchmark-ips
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
71
85
|
description: A StatsD client for Ruby apps. Provides metaprogramming methods to inject
|
72
86
|
StatsD instrumentation into your code.
|
73
87
|
email:
|
@@ -99,6 +113,7 @@ files:
|
|
99
113
|
- shipit.rubygems.yml
|
100
114
|
- statsd-instrument.gemspec
|
101
115
|
- test/assertions_test.rb
|
116
|
+
- test/benchmark/tags.rb
|
102
117
|
- test/capture_backend_test.rb
|
103
118
|
- test/environment_test.rb
|
104
119
|
- test/integration_test.rb
|
@@ -134,6 +149,7 @@ specification_version: 4
|
|
134
149
|
summary: A StatsD client for Ruby apps
|
135
150
|
test_files:
|
136
151
|
- test/assertions_test.rb
|
152
|
+
- test/benchmark/tags.rb
|
137
153
|
- test/capture_backend_test.rb
|
138
154
|
- test/environment_test.rb
|
139
155
|
- test/integration_test.rb
|