dogstatsd-ruby 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/statsd.rb +15 -25
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8524384a22231a55a17d5716136f4f5bf2f3bcf2
|
4
|
+
data.tar.gz: 7e4c50e0ff11758392fba14d7008c48cdfd0c020
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69db873d5dc0836a5614a9b5ab97188bffedddb8d840ee7a34bd50bfeba6a57f239a72526d92280bf64b8084b956c980815bb06fdf588bc76ad2250762f46036
|
7
|
+
data.tar.gz: 397ed964d3ed6557a70991e9b32371ee8c020195d46c6b970ac46ed8afe338178c3cfa2e3c875649f0f373fbb61b4b0dafedcdcebc7eaaed883469bc5eb5af2c
|
data/lib/statsd.rb
CHANGED
@@ -69,7 +69,7 @@ class Statsd
|
|
69
69
|
|
70
70
|
# Return the current version of the library.
|
71
71
|
def self.VERSION
|
72
|
-
"1.
|
72
|
+
"1.6.0"
|
73
73
|
end
|
74
74
|
|
75
75
|
# @param [String] host your statsd host
|
@@ -238,20 +238,15 @@ class Statsd
|
|
238
238
|
SC_OPT_KEYS.each do |name_key|
|
239
239
|
if opts[name_key[0].to_sym]
|
240
240
|
if name_key[0] == 'tags'
|
241
|
-
tags = opts[:tags]
|
242
|
-
tags.each do |tag|
|
243
|
-
rm_pipes tag
|
244
|
-
end
|
241
|
+
tags = opts[:tags].map {|tag| remove_pipes(tag) }
|
245
242
|
tags = "#{tags.join(",")}" unless tags.empty?
|
246
243
|
sc_string << "|##{tags}"
|
247
244
|
elsif name_key[0] == 'message'
|
248
|
-
message = opts[:message]
|
249
|
-
|
250
|
-
|
251
|
-
sc_string << "|m:#{message}"
|
245
|
+
message = remove_pipes(opts[:message])
|
246
|
+
escaped_message = escape_service_check_message(message)
|
247
|
+
sc_string << "|m:#{escaped_message}"
|
252
248
|
else
|
253
|
-
value = opts[name_key[0].to_sym]
|
254
|
-
rm_pipes value
|
249
|
+
value = remove_pipes(opts[name_key[0].to_sym])
|
255
250
|
sc_string << "|#{name_key[1]}#{value}"
|
256
251
|
end
|
257
252
|
end
|
@@ -300,25 +295,21 @@ class Statsd
|
|
300
295
|
end
|
301
296
|
|
302
297
|
def format_event(title, text, opts={})
|
303
|
-
escape_event_content
|
304
|
-
escape_event_content
|
305
|
-
event_string_data = "_e{#{
|
298
|
+
escaped_title = escape_event_content(title)
|
299
|
+
escaped_text = escape_event_content(text)
|
300
|
+
event_string_data = "_e{#{escaped_title.length},#{escaped_text.length}}:#{escaped_title}|#{escaped_text}"
|
306
301
|
|
307
302
|
# We construct the string to be sent by adding '|key:value' parts to it when needed
|
308
303
|
# All pipes ('|') in the metadata are removed. Title and Text can keep theirs
|
309
304
|
OPTS_KEYS.each do |name_key|
|
310
305
|
if name_key[0] != 'tags' && opts[name_key[0].to_sym]
|
311
|
-
value = opts[name_key[0].to_sym]
|
312
|
-
rm_pipes value
|
306
|
+
value = remove_pipes(opts[name_key[0].to_sym])
|
313
307
|
event_string_data << "|#{name_key[1]}:#{value}"
|
314
308
|
end
|
315
309
|
end
|
316
|
-
full_tags = tags + (opts[:tags] || [])
|
317
310
|
# Tags are joined and added as last part to the string to be sent
|
311
|
+
full_tags = (tags + (opts[:tags] || [])).map {|tag| remove_pipes(tag) }
|
318
312
|
unless full_tags.empty?
|
319
|
-
full_tags.each do |tag|
|
320
|
-
rm_pipes tag
|
321
|
-
end
|
322
313
|
event_string_data << "|##{full_tags.join(',')}"
|
323
314
|
end
|
324
315
|
|
@@ -329,16 +320,15 @@ class Statsd
|
|
329
320
|
private
|
330
321
|
|
331
322
|
def escape_event_content(msg)
|
332
|
-
msg.gsub
|
323
|
+
msg.gsub "\n", "\\n"
|
333
324
|
end
|
334
325
|
|
335
|
-
def
|
336
|
-
msg.gsub
|
326
|
+
def remove_pipes(msg)
|
327
|
+
msg.gsub "|", ""
|
337
328
|
end
|
338
329
|
|
339
330
|
def escape_service_check_message(msg)
|
340
|
-
msg.gsub
|
341
|
-
msg.gsub! "\n", "\\n"
|
331
|
+
msg.gsub('m:', 'm\:').gsub "\n", "\\n"
|
342
332
|
end
|
343
333
|
|
344
334
|
def time_since(stat, start, opts)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dogstatsd-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rein Henrichs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -97,8 +97,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.4.8
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: A Ruby DogStatsd client
|
104
104
|
test_files: []
|
105
|
+
has_rdoc:
|