dogstatsd-ruby 5.6.0 → 5.6.2

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: 20363c18876c0641ab23a8cee8d28c22de3e4210420e398d639d6a7b384da168
4
- data.tar.gz: 851d63e75192dd81451f7a94abba7efe5c81e9c4afdc2dce8102a76e44a10d9a
3
+ metadata.gz: fb5fc01f7ac477b0d99986331aba69b1556b2160246ff379a60f394be8fb0968
4
+ data.tar.gz: fc254d901ec1071acbef8fa724e30f54b0fd4c65592a726e68805ea484c54811
5
5
  SHA512:
6
- metadata.gz: 72f565700a7ddf32ca56a686617e840c53ad167770be812a66ad6af5d1641c96f89796fe147c1565c38c7d83be14fc638e0f8ce76a00e62e980f43a510826d18
7
- data.tar.gz: 659bbd4b5b669a11bf62f723387d0263d76a243bda5c6b5de101700b20ad2991d6fd6535832857acdd15b0f809faff80cb1e9f459e1ddacb3262a6be27c4785f
6
+ metadata.gz: 719c9f76ce1cc501fddff67f3e563eec94d612c40b8b29aa93bed1c270bc4d6d785eed088d5f4df513034f4eff38b1c1e67f2538c86372b07f353f29f6f0a18c
7
+ data.tar.gz: 7b2812a927a160ec0452e3366ed0eed9166ec95ecf88dc8ab325726d18e60d683d8bfb75845608f1e025a6af80871acd8a6e4d16a08c4d21c749731b1d327643
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,18 @@ 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('::', '.')
40
+ def formatted_metric_name(metric_name)
41
+ formatted = Symbol === metric_name ? metric_name.name : metric_name.to_s
42
+
43
+ if formatted.include?('::')
44
+ formatted = formatted.gsub('::', '.')
45
+ formatted.tr!(':|@', '_')
46
+ formatted
47
+ elsif formatted.include?(':') || formatted.include?('@') || formatted.include?('|')
48
+ formatted.tr(':|@', '_')
44
49
  else
45
- formated = name.to_s
46
- formated.gsub!('::', '.')
50
+ formatted
47
51
  end
48
-
49
- formated.tr!(':|@', '_')
50
- formated
51
52
  end
52
53
  end
53
54
  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)
@@ -29,7 +29,9 @@ module Datadog
29
29
  def connect
30
30
  close if @socket
31
31
 
32
- @socket = UDPSocket.new
32
+ family = Addrinfo.udp(host, port).afamily
33
+
34
+ @socket = UDPSocket.new(family)
33
35
  @socket.connect(host, port)
34
36
  end
35
37
 
@@ -4,6 +4,6 @@ require_relative 'connection'
4
4
 
5
5
  module Datadog
6
6
  class Statsd
7
- VERSION = '5.6.0'
7
+ VERSION = '5.6.2'
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.0
4
+ version: 5.6.2
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-07-10 00:00:00.000000000 Z
12
+ date: 2024-09-20 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.0/CHANGELOG.md
48
- documentation_uri: https://www.rubydoc.info/gems/dogstatsd-ruby/5.6.0
49
- source_code_uri: https://github.com/DataDog/dogstatsd-ruby/tree/v5.6.0
47
+ changelog_uri: https://github.com/DataDog/dogstatsd-ruby/blob/v5.6.2/CHANGELOG.md
48
+ documentation_uri: https://www.rubydoc.info/gems/dogstatsd-ruby/5.6.2
49
+ source_code_uri: https://github.com/DataDog/dogstatsd-ruby/tree/v5.6.2
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.1.6
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: A Ruby DogStatsd client