Skip to content

Commit

Permalink
Merge pull request #60 from Shopify/even-faster-tags
Browse files Browse the repository at this point in the history
metric: replacing :: is not needed for statsd protocol
  • Loading branch information
wvanbergen committed Jun 29, 2015
2 parents 90bb849 + 7dc2868 commit 1b60877
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/statsd/instrument/metric.rb
Expand Up @@ -101,8 +101,8 @@ def inspect
# @param tags [Array<String>, Hash<String, String>, nil] Tags specified in any form.
# @return [Array<String>, nil] the list of tags in canonical form.
def self.normalize_tags(tags)
return if tags.nil?
tags = tags.map { |k, v| "#{k.to_s.tr(':', '')}:#{v.to_s.tr(':', '')}" } if tags.is_a?(Hash)
return unless tags
tags = tags.map { |k, v| k.to_s + ":".freeze + v.to_s } if tags.is_a?(Hash)
tags.map { |tag| tag.tr('|,'.freeze, ''.freeze) }
end
end
2 changes: 1 addition & 1 deletion test/metric_test.rb
Expand Up @@ -26,7 +26,7 @@ def test_name_prefix

def test_handle_bad_tags
assert_equal ['ignored'], StatsD::Instrument::Metric.normalize_tags(['igno|red'])
assert_equal ['lolclass:omglol'], StatsD::Instrument::Metric.normalize_tags({ :"lol::class" => "omg::lol" })
assert_equal ['lol::class:omg::lol'], StatsD::Instrument::Metric.normalize_tags({ :"lol::class" => "omg::lol" })
end

def test_rewrite_tags_provided_as_hash
Expand Down

0 comments on commit 1b60877

Please sign in to comment.