dogstatsd-ruby 4.8.1 → 4.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/datadog/statsd/serialization/stat_serializer.rb +22 -29
- data/lib/datadog/statsd/serialization/tag_serializer.rb +16 -15
- data/lib/datadog/statsd/version.rb +1 -1
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dca98cecf21fceb3e5a4c4e76ceb8be8ffa2032ad317d63d1b3df7817dd60ef7
|
4
|
+
data.tar.gz: 0ef534d77693c3f1efbd8e8c8e1399f54ee6664e1044a16c913e4f9fa302e3d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d95681cd4c29de465efb5f6429227716d5cf4c6d1c57d1d5f6ba06cae2297b6ac06a961763a800b7997e6bf0011fa6f922826fdea7842fde536943c151c8e050
|
7
|
+
data.tar.gz: 0b560868db6815d18283ae938536c234d169e5aba4e1d602ee97759b36ad19fab626297b56cecf07b426c14de211e4bab43a010474e51a347387f82cd0c9cabe
|
data/README.md
CHANGED
@@ -71,6 +71,19 @@ After the client is created, you can start sending events to your Datadog Event
|
|
71
71
|
|
72
72
|
After the client is created, you can start sending Service Checks to Datadog. See the dedicated [Service Check Submission: DogStatsD documentation](https://docs.datadoghq.com/developers/service_checks/dogstatsd_service_checks_submission/?tab=ruby) to see how to submit a Service Check to Datadog.
|
73
73
|
|
74
|
+
### Maximum packets size in high-throughput scenarios
|
75
|
+
|
76
|
+
In order to have the most efficient use of this library in high-throughput scenarios,
|
77
|
+
default values for the maximum packets size have already been set for both UDS (8192 bytes)
|
78
|
+
and UDP (1432 bytes) in order to have the best usage of the underlying network.
|
79
|
+
However, if you perfectly know your network and you know that a different value for the maximum packets
|
80
|
+
size should be used, you can set it with the parameter `buffer_max_payload_size`. Example:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
# Create a DogStatsD client instance.
|
84
|
+
statsd = Datadog::Statsd.new('localhost', 8125, buffer_max_payload_size: 4096)
|
85
|
+
```
|
86
|
+
|
74
87
|
## Credits
|
75
88
|
|
76
89
|
dogstatsd-ruby is forked from Rien Henrichs [original Statsd
|
@@ -6,34 +6,24 @@ module Datadog
|
|
6
6
|
class StatSerializer
|
7
7
|
def initialize(prefix, global_tags: [])
|
8
8
|
@prefix = prefix
|
9
|
+
@prefix_str = prefix.to_s
|
9
10
|
@tag_serializer = TagSerializer.new(global_tags)
|
10
11
|
end
|
11
12
|
|
12
13
|
def format(name, delta, type, tags: [], sample_rate: 1)
|
13
|
-
|
14
|
-
stat << prefix if prefix
|
15
|
-
|
16
|
-
# stat value
|
17
|
-
stat << formated_name(name)
|
18
|
-
stat << ':'
|
19
|
-
stat << delta.to_s
|
20
|
-
|
21
|
-
# stat type
|
22
|
-
stat << '|'
|
23
|
-
stat << type
|
24
|
-
|
25
|
-
# sample_rate
|
26
|
-
if sample_rate != 1
|
27
|
-
stat << '|'
|
28
|
-
stat << '@'
|
29
|
-
stat << sample_rate.to_s
|
30
|
-
end
|
14
|
+
name = formated_name(name)
|
31
15
|
|
32
|
-
|
16
|
+
if sample_rate != 1
|
17
|
+
if tags_list = tag_serializer.format(tags)
|
18
|
+
"#{@prefix_str}#{name}:#{delta}|#{type}|@#{sample_rate}|##{tags_list}"
|
19
|
+
else
|
20
|
+
"#{@prefix_str}#{name}:#{delta}|#{type}|@#{sample_rate}"
|
21
|
+
end
|
22
|
+
else
|
33
23
|
if tags_list = tag_serializer.format(tags)
|
34
|
-
|
35
|
-
|
36
|
-
|
24
|
+
"#{@prefix_str}#{name}:#{delta}|#{type}|##{tags_list}"
|
25
|
+
else
|
26
|
+
"#{@prefix_str}#{name}:#{delta}|#{type}"
|
37
27
|
end
|
38
28
|
end
|
39
29
|
end
|
@@ -43,18 +33,21 @@ module Datadog
|
|
43
33
|
end
|
44
34
|
|
45
35
|
private
|
36
|
+
|
46
37
|
attr_reader :prefix
|
47
38
|
attr_reader :tag_serializer
|
48
39
|
|
49
40
|
def formated_name(name)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
f.tr!(':|@', '_')
|
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!('::', '.')
|
57
47
|
end
|
48
|
+
|
49
|
+
formated.tr!(':|@', '_')
|
50
|
+
formated
|
58
51
|
end
|
59
52
|
end
|
60
53
|
end
|
@@ -13,18 +13,21 @@ module Datadog
|
|
13
13
|
|
14
14
|
# Convert to tag list and set
|
15
15
|
@global_tags = to_tags_list(global_tags)
|
16
|
+
@global_tags_formatted = @global_tags.join(',') if @global_tags.any?
|
16
17
|
end
|
17
18
|
|
18
19
|
def format(message_tags)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
if !message_tags || message_tags.empty?
|
21
|
+
return @global_tags_formatted
|
22
|
+
end
|
23
|
+
|
24
|
+
tags = if @global_tags_formatted
|
25
|
+
[@global_tags_formatted, to_tags_list(message_tags)]
|
26
|
+
else
|
27
|
+
to_tags_list(message_tags)
|
28
|
+
end
|
26
29
|
|
27
|
-
|
30
|
+
tags.join(',')
|
28
31
|
end
|
29
32
|
|
30
33
|
attr_reader :global_tags
|
@@ -51,19 +54,17 @@ module Datadog
|
|
51
54
|
def to_tags_list(tags)
|
52
55
|
case tags
|
53
56
|
when Hash
|
54
|
-
tags.
|
55
|
-
if
|
56
|
-
|
57
|
+
tags.map do |name, value|
|
58
|
+
if value
|
59
|
+
escape_tag_content("#{name}:#{value}")
|
57
60
|
else
|
58
|
-
|
61
|
+
escape_tag_content(name)
|
59
62
|
end
|
60
63
|
end
|
61
64
|
when Array
|
62
|
-
tags.
|
65
|
+
tags.map { |tag| escape_tag_content(tag) }
|
63
66
|
else
|
64
67
|
[]
|
65
|
-
end.map! do |tag|
|
66
|
-
escape_tag_content(tag)
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
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: 4.8.
|
4
|
+
version: 4.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rein Henrichs
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Ruby DogStastd client
|
14
14
|
email: code@datadoghq.com
|
@@ -38,10 +38,10 @@ licenses:
|
|
38
38
|
- MIT
|
39
39
|
metadata:
|
40
40
|
bug_tracker_uri: https://github.com/DataDog/dogstatsd-ruby/issues
|
41
|
-
changelog_uri: https://github.com/DataDog/dogstatsd-ruby/blob/v4.8.
|
42
|
-
documentation_uri: https://www.rubydoc.info/gems/dogstatsd-ruby/4.8.
|
43
|
-
source_code_uri: https://github.com/DataDog/dogstatsd-ruby/tree/v4.8.
|
44
|
-
post_install_message:
|
41
|
+
changelog_uri: https://github.com/DataDog/dogstatsd-ruby/blob/v4.8.2/CHANGELOG.md
|
42
|
+
documentation_uri: https://www.rubydoc.info/gems/dogstatsd-ruby/4.8.2
|
43
|
+
source_code_uri: https://github.com/DataDog/dogstatsd-ruby/tree/v4.8.2
|
44
|
+
post_install_message:
|
45
45
|
rdoc_options: []
|
46
46
|
require_paths:
|
47
47
|
- lib
|
@@ -56,8 +56,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '0'
|
58
58
|
requirements: []
|
59
|
-
|
60
|
-
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.7.10
|
61
|
+
signing_key:
|
61
62
|
specification_version: 4
|
62
63
|
summary: A Ruby DogStatsd client
|
63
64
|
test_files: []
|