Class: Datadog::Statsd::Serialization::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/statsd/serialization/serializer.rb

Instance Method Summary collapse

Constructor Details

#initialize(prefix: nil, global_tags: []) ⇒ Serializer

Returns a new instance of Serializer.



9
10
11
12
13
# File 'lib/datadog/statsd/serialization/serializer.rb', line 9

def initialize(prefix: nil, global_tags: [])
  @stat_serializer = StatSerializer.new(prefix, global_tags: global_tags)
  @service_check_serializer = ServiceCheckSerializer.new(global_tags: global_tags)
  @event_serializer = EventSerializer.new(global_tags: global_tags)
end

Instance Method Details

#global_tagsObject



30
31
32
# File 'lib/datadog/statsd/serialization/serializer.rb', line 30

def global_tags
  stat_serializer.global_tags
end

#to_event(title, text, options = EMPTY_OPTIONS) ⇒ Object

using *args would make new allocations



26
27
28
# File 'lib/datadog/statsd/serialization/serializer.rb', line 26

def to_event(title, text, options = EMPTY_OPTIONS)
  event_serializer.format(title, text, options)
end

#to_service_check(name, status, options = EMPTY_OPTIONS) ⇒ Object

using *args would make new allocations



21
22
23
# File 'lib/datadog/statsd/serialization/serializer.rb', line 21

def to_service_check(name, status, options = EMPTY_OPTIONS)
  service_check_serializer.format(name, status, options)
end

#to_stat(name, delta, type, tags: [], sample_rate: 1) ⇒ Object

using *args would make new allocations



16
17
18
# File 'lib/datadog/statsd/serialization/serializer.rb', line 16

def to_stat(name, delta, type, tags: [], sample_rate: 1)
  stat_serializer.format(name, delta, type, tags: tags, sample_rate: sample_rate)
end