Class: Datadog::Statsd::Serialization::ServiceCheckSerializer
- Inherits:
-
Object
- Object
- Datadog::Statsd::Serialization::ServiceCheckSerializer
- Defined in:
- lib/datadog/statsd/serialization/service_check_serializer.rb
Constant Summary collapse
- SERVICE_CHECK_BASIC_OPTIONS =
{ timestamp: 'd:', hostname: 'h:', }.freeze
Instance Method Summary collapse
- #format(name, status, options = EMPTY_OPTIONS) ⇒ Object
-
#initialize(global_tags: []) ⇒ ServiceCheckSerializer
constructor
A new instance of ServiceCheckSerializer.
Constructor Details
#initialize(global_tags: []) ⇒ ServiceCheckSerializer
Returns a new instance of ServiceCheckSerializer.
12 13 14 |
# File 'lib/datadog/statsd/serialization/service_check_serializer.rb', line 12 def initialize(global_tags: []) @tag_serializer = TagSerializer.new() end |
Instance Method Details
#format(name, status, options = EMPTY_OPTIONS) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/datadog/statsd/serialization/service_check_serializer.rb', line 16 def format(name, status, = EMPTY_OPTIONS) String.new.tap do |service_check| # line basics service_check << "_sc" service_check << "|" service_check << name.to_s service_check << "|" service_check << status.to_s # we are serializing the generic service check options # before serializing specialized options that need edge-cases SERVICE_CHECK_BASIC_OPTIONS.each do |option_key, shortcut| if value = [option_key] service_check << '|' service_check << shortcut service_check << value.to_s.delete('|') end end if = [:message] service_check << '|m:' service_check << () end # also returns the global tags from serializer if = tag_serializer.format([:tags]) service_check << '|#' service_check << end end end |