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(metric_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 11 |
# File 'lib/datadog/statsd/serialization/stat_serializer.rb', line 7 def initialize(prefix, global_tags: []) @prefix = prefix @prefix_str = prefix.to_s @tag_serializer = TagSerializer.new() end |
Instance Method Details
#format(metric_name, delta, type, tags: [], sample_rate: 1) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/datadog/statsd/serialization/stat_serializer.rb', line 13 def format(metric_name, delta, type, tags: [], sample_rate: 1) metric_name = formatted_metric_name(metric_name) if sample_rate != 1 if = tag_serializer.format() "#{@prefix_str}#{metric_name}:#{delta}|#{type}|@#{sample_rate}|##{}" else "#{@prefix_str}#{metric_name}:#{delta}|#{type}|@#{sample_rate}" end else if = tag_serializer.format() "#{@prefix_str}#{metric_name}:#{delta}|#{type}|##{}" else "#{@prefix_str}#{metric_name}:#{delta}|#{type}" end end end |
#global_tags ⇒ Object
31 32 33 |
# File 'lib/datadog/statsd/serialization/stat_serializer.rb', line 31 def tag_serializer. end |