statsd-instrument 2.0.6 → 2.0.7

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
  SHA1:
3
- metadata.gz: 852b64cbebc0760778a4d3332d4611f4652e64bd
4
- data.tar.gz: fb0025c42ec04d18f7bdd1553d48dd75656e083f
3
+ metadata.gz: 332aeb4ca9870d03b48fae2f8322f81396e0a70b
4
+ data.tar.gz: aabec4e189d0e494b77be52fe604a43548b8f4c5
5
5
  SHA512:
6
- metadata.gz: 58f1b9bf3fee6706e3bc543d4f0146dda3217c0dab443a624d9700f02083917d6a76169dbf0cd1d9372ed8f36ff9b51a9bfbf6cb121f62fa8c4e0798b48f86cc
7
- data.tar.gz: f9a3abf6573ac684c6573c64dec24108ab0e6c56227ced05a6fa167dc0e4c4d0245b83dcdd53f2de2666e9138096b3668ed1f86529937ae06a70833e57849dc5
6
+ metadata.gz: b2f06ab8c82e1bfc4f2dfcedc9984d05ec7797e125da782dbca2fe4c60ba2948ec2920e8f3fcdee61e660568f6e2ab961b7694be7f29092f7c29a46d5925f30b
7
+ data.tar.gz: 9d1e015f071f34af4ca7294269ce923b05222e1297ed798adec1c8d080310fc878e76ece7c7a50dd2a5bf2366d421b4f0d07f437c7a3f38d8c2885e5bf8501a3
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ doc
4
4
  .bundle
5
5
  Gemfile.lock
6
6
  pkg/*
7
+ vendor/
data/.travis.yml CHANGED
@@ -1,11 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.1
6
- - ruby-head
3
+ - 2.0
4
+ - 2.1
5
+ - 2.2
7
6
  - jruby-19mode
8
7
  - rbx-2
8
+ - ruby-head
9
9
 
10
10
  matrix:
11
11
  allow_failures:
data/CHANGELOG.md CHANGED
@@ -5,9 +5,8 @@ please at an entry to the "unreleased changes" section below.
5
5
 
6
6
  ### Unreleased changes
7
7
 
8
- - Nothing yet!
9
-
10
- ---
8
+ - Drop support for Ruby 1.9.3.
9
+ - Add support for Ruby 2.2.
11
10
 
12
11
  ### Version 2.0.6
13
12
 
data/README.md CHANGED
@@ -261,7 +261,7 @@ end
261
261
 
262
262
  ### Compatibility
263
263
 
264
- Tested using Travis CI against Ruby 1.9.3, Ruby 2.0.0, Ruby 2.1.1, Rubinius, and JRuby
264
+ Tested using Travis CI against Ruby 2.0, 2.1, 2.2, Rubinius, and JRuby.
265
265
 
266
266
  ### Reliance on DNS
267
267
 
@@ -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 do |tag|
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
@@ -1,5 +1,5 @@
1
1
  module StatsD
2
2
  module Instrument
3
- VERSION = "2.0.6"
3
+ VERSION = "2.0.7"
4
4
  end
5
5
  end
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency 'minitest'
23
23
  spec.add_development_dependency 'mocha'
24
24
  spec.add_development_dependency 'yard'
25
+ spec.add_development_dependency 'benchmark-ips'
25
26
  end
@@ -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 test_rewrite_shitty_tags
28
- assert_equal ['igno_red'], StatsD::Instrument::Metric.normalize_tags(['igno,red'])
29
- assert_equal ['igno_red'], StatsD::Instrument::Metric.normalize_tags(['igno red'])
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.6
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-02-02 00:00:00.000000000 Z
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