dogstatsd-ruby 5.6.1 → 5.6.3

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
  SHA256:
3
- metadata.gz: 8069234fd7b43382f85606fa53a858c502025937168c275347a0ec5552f566fc
4
- data.tar.gz: 81945812b5810033cc2f511364d3a962a1c932e771d4faa2a4366391fe447414
3
+ metadata.gz: 2f866425de553f6c35e54932dcfa114094ffca6061c8db730f81ebc7a6dbcca5
4
+ data.tar.gz: 8fd14544e331d78fc05d4530d5f0226cc4c654f91f86ad8a6dfbd4699af719ed
5
5
  SHA512:
6
- metadata.gz: 5b589a6f599dc547f980587c8902eed4012b4d627fd6abe28c21829f299ee695e33f38f2fe386fb3d9f7828327134f69831f0365ee4ff16d84b7de3830178081
7
- data.tar.gz: 05cb95baf12dbe3b2f17c835c8278f32198ce21d2d66ca14b4714aa90a12dd6a4976c48e9d9f326ca51cc66d95c83dd269e55aa6fe6e08409c61cec8866a9798
6
+ metadata.gz: 68852fd8801cc884e7df8f23377479156185065f279270758b9c668a1167019dae6fcb7a5cb818457bcc08644e86b308f91813467d7c45a323c9eb3bd57197b6
7
+ data.tar.gz: e921bc57cc7d68765189f4314e22652a4979ca9d043b76cd50c39b0cce884bd90dac600d8b2b890113b6c480cd2487de1d02d93864bc29f60e839ebaa45e508e
data/README.md CHANGED
@@ -226,7 +226,7 @@ As much as possible, we will add a "future deprecation" message in the minor rel
226
226
 
227
227
  ## Ruby Versions
228
228
 
229
- This gem supports and is tested on Ruby minor versions 2.1 through 3.1.
229
+ This gem supports and is tested on Ruby minor versions 2.1 through 3.3.
230
230
  Support for Ruby 2.0 was dropped in version 5.4.0.
231
231
 
232
232
  ## Credits
@@ -28,7 +28,8 @@ module Datadog
28
28
  # Serializes the message if it hasn't been already. Part of the
29
29
  # delay_serialization feature.
30
30
  if message.is_a?(Array)
31
- message = @serializer.to_stat(*message[0], **message[1])
31
+ stat, delta, type, tags, sample_rate = message
32
+ message = @serializer.to_stat(stat, delta, type, tags: tags, sample_rate: sample_rate)
32
33
  end
33
34
 
34
35
  message_size = message.bytesize
@@ -10,20 +10,20 @@ module Datadog
10
10
  @tag_serializer = TagSerializer.new(global_tags)
11
11
  end
12
12
 
13
- def format(name, delta, type, tags: [], sample_rate: 1)
14
- name = formated_name(name)
13
+ def format(metric_name, delta, type, tags: [], sample_rate: 1)
14
+ metric_name = formatted_metric_name(metric_name)
15
15
 
16
16
  if sample_rate != 1
17
17
  if tags_list = tag_serializer.format(tags)
18
- "#{@prefix_str}#{name}:#{delta}|#{type}|@#{sample_rate}|##{tags_list}"
18
+ "#{@prefix_str}#{metric_name}:#{delta}|#{type}|@#{sample_rate}|##{tags_list}"
19
19
  else
20
- "#{@prefix_str}#{name}:#{delta}|#{type}|@#{sample_rate}"
20
+ "#{@prefix_str}#{metric_name}:#{delta}|#{type}|@#{sample_rate}"
21
21
  end
22
22
  else
23
23
  if tags_list = tag_serializer.format(tags)
24
- "#{@prefix_str}#{name}:#{delta}|#{type}|##{tags_list}"
24
+ "#{@prefix_str}#{metric_name}:#{delta}|#{type}|##{tags_list}"
25
25
  else
26
- "#{@prefix_str}#{name}:#{delta}|#{type}"
26
+ "#{@prefix_str}#{metric_name}:#{delta}|#{type}"
27
27
  end
28
28
  end
29
29
  end
@@ -37,17 +37,27 @@ module Datadog
37
37
  attr_reader :prefix
38
38
  attr_reader :tag_serializer
39
39
 
40
- def formated_name(name)
41
- if name.is_a?(String)
42
- # DEV: gsub is faster than dup.gsub!
43
- formated = name.gsub('::', '.')
44
- else
45
- formated = name.to_s
46
- formated.gsub!('::', '.')
40
+ if RUBY_VERSION < '3'
41
+ def metric_name_to_string(metric_name)
42
+ metric_name.to_s
43
+ end
44
+ else
45
+ def metric_name_to_string(metric_name)
46
+ Symbol === metric_name ? metric_name.name : metric_name.to_s
47
47
  end
48
+ end
48
49
 
49
- formated.tr!(':|@', '_')
50
- formated
50
+ def formatted_metric_name(metric_name)
51
+ formatted = metric_name_to_string(metric_name)
52
+ if formatted.include?('::')
53
+ formatted = formatted.gsub('::', '.')
54
+ formatted.tr!(':|@', '_')
55
+ formatted
56
+ elsif formatted.include?(':') || formatted.include?('@') || formatted.include?('|')
57
+ formatted.tr(':|@', '_')
58
+ else
59
+ formatted
60
+ end
51
61
  end
52
62
  end
53
63
  end
@@ -73,7 +73,9 @@ module Datadog
73
73
  end
74
74
 
75
75
  def escape_tag_content(tag)
76
- tag.to_s.delete('|,')
76
+ tag = tag.to_s
77
+ return tag unless tag.include?('|')
78
+ tag.delete('|,')
77
79
  end
78
80
 
79
81
  def dd_tags(env = ENV)
@@ -4,6 +4,6 @@ require_relative 'connection'
4
4
 
5
5
  module Datadog
6
6
  class Statsd
7
- VERSION = '5.6.1'
7
+ VERSION = '5.6.3'
8
8
  end
9
9
  end
@@ -431,7 +431,7 @@ module Datadog
431
431
  if sample_rate == 1 || opts[:pre_sampled] || rand <= sample_rate
432
432
  full_stat =
433
433
  if @delay_serialization
434
- [[stat, delta, type], {tags: opts[:tags], sample_rate: sample_rate}]
434
+ [stat, delta, type, opts[:tags], sample_rate]
435
435
  else
436
436
  serializer.to_stat(stat, delta, type, tags: opts[:tags], sample_rate: sample_rate)
437
437
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dogstatsd-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.1
4
+ version: 5.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rein Henrichs
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-09-07 00:00:00.000000000 Z
12
+ date: 2024-11-04 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A Ruby DogStatsd client
15
15
  email: code@datadoghq.com
@@ -44,9 +44,9 @@ licenses:
44
44
  - MIT
45
45
  metadata:
46
46
  bug_tracker_uri: https://github.com/DataDog/dogstatsd-ruby/issues
47
- changelog_uri: https://github.com/DataDog/dogstatsd-ruby/blob/v5.6.1/CHANGELOG.md
48
- documentation_uri: https://www.rubydoc.info/gems/dogstatsd-ruby/5.6.1
49
- source_code_uri: https://github.com/DataDog/dogstatsd-ruby/tree/v5.6.1
47
+ changelog_uri: https://github.com/DataDog/dogstatsd-ruby/blob/v5.6.3/CHANGELOG.md
48
+ documentation_uri: https://www.rubydoc.info/gems/dogstatsd-ruby/5.6.3
49
+ source_code_uri: https://github.com/DataDog/dogstatsd-ruby/tree/v5.6.3
50
50
  post_install_message: |2+
51
51
 
52
52
  If you are upgrading from v4.x of the dogstatsd-ruby library, note the major change to the threading model:
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
- rubygems_version: 3.2.3
69
+ rubygems_version: 3.4.6
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: A Ruby DogStatsd client