Class: NewRelic::Agent::CustomEventAggregator

Inherits:
EventAggregator show all
Includes:
Coerce
Defined in:
lib/new_relic/agent/custom_event_aggregator.rb

Constant Summary collapse

TYPE =
'type'.freeze
TIMESTAMP =
'timestamp'.freeze
PRIORITY =
'priority'.freeze
EVENT_TYPE_REGEX =
/^[a-zA-Z0-9:_ ]+$/.freeze
MAX_ATTRIBUTE_COUNT =
64
MAX_ATTRIBUTE_SIZE =
4095
MAX_NAME_SIZE =
255

Instance Method Summary collapse

Methods included from Coerce

boolean_int!, float, float!, int, int!, int_or_nil, log_failure, scalar, string, value_or_nil

Methods inherited from EventAggregator

buffer_class, capacity_key, #enabled?, enabled_fn, enabled_keys, #harvest!, #has_metadata?, #initialize, #merge!, named, #reset!

Constructor Details

This class inherits a constructor from NewRelic::Agent::EventAggregator

Instance Method Details

#record(type, attributes) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/new_relic/agent/custom_event_aggregator.rb', line 25

def record(type, attributes)
  unless attributes.is_a?(Hash)
    raise ArgumentError, "Expected Hash but got #{attributes.class}"
  end

  return unless enabled?

  type = @type_strings[type]
  unless EVENT_TYPE_REGEX.match?(type)
    note_dropped_event(type)
    return false
  end

  priority = attributes[:priority] || rand

  stored = @lock.synchronize do
    @buffer.append(priority: priority) do
      create_event(type, priority, attributes)
    end
  end
  stored
end