Class: Datadog::Statsd::Serialization::StatSerializer
- Inherits:
-
Object
- Object
- Datadog::Statsd::Serialization::StatSerializer
- Defined in:
- lib/datadog/statsd/serialization/stat_serializer.rb
Instance Method Summary collapse
- #format(name, delta, type, tags: [], sample_rate: 1) ⇒ Object
- #global_tags ⇒ Object
-
#initialize(prefix, global_tags: []) ⇒ StatSerializer
constructor
A new instance of StatSerializer.
Constructor Details
#initialize(prefix, global_tags: []) ⇒ StatSerializer
Returns a new instance of StatSerializer.
7 8 9 10 |
# File 'lib/datadog/statsd/serialization/stat_serializer.rb', line 7 def initialize(prefix, global_tags: []) @prefix = prefix @tag_serializer = TagSerializer.new() end |
Instance Method Details
#format(name, delta, type, tags: [], sample_rate: 1) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/datadog/statsd/serialization/stat_serializer.rb', line 12 def format(name, delta, type, tags: [], sample_rate: 1) String.new.tap do |stat| stat << prefix if prefix # stat value stat << formated_name(name) stat << ':' stat << delta.to_s # stat type stat << '|' stat << type # sample_rate if sample_rate != 1 stat << '|' stat << '@' stat << sample_rate.to_s end # tags if = tag_serializer.format() stat << '|' stat << '#' stat << end end end |
#global_tags ⇒ Object
41 42 43 |
# File 'lib/datadog/statsd/serialization/stat_serializer.rb', line 41 def tag_serializer. end |