class NewRelic::Agent::CustomEventAggregator
Constants
- EVENT_TYPE_REGEX
- TIMESTAMP
- TYPE
Public Instance Methods
record(type, attributes)
click to toggle source
# File lib/new_relic/agent/custom_event_aggregator.rb, line 20 def record(type, attributes) unless attributes.is_a? Hash raise ArgumentError, "Expected Hash but got #{attributes.class}" end type = @type_strings[type] unless type =~ EVENT_TYPE_REGEX note_dropped_event(type) return false end event = [ { TYPE => type, TIMESTAMP => Time.now.to_i }, AttributeProcessing.flatten_and_coerce(attributes) ] stored = @lock.synchronize do @buffer.append(event) end stored end
Private Instance Methods
after_harvest(metadata)
click to toggle source
# File lib/new_relic/agent/custom_event_aggregator.rb, line 48 def after_harvest metadata dropped_count = metadata[:seen] - metadata[:captured] note_dropped_events(metadata[:seen], dropped_count) record_supportability_metrics(metadata[:seen], metadata[:captured], dropped_count) end
after_initialize()
click to toggle source
# File lib/new_relic/agent/custom_event_aggregator.rb, line 44 def after_initialize @type_strings = Hash.new { |hash, key| hash[key] = key.to_s.freeze } end
note_dropped_event(type)
click to toggle source
# File lib/new_relic/agent/custom_event_aggregator.rb, line 67 def note_dropped_event(type) ::NewRelic::Agent.logger.log_once(:warn, "dropping_event_of_type:#{type}", "Invalid event type name '#{type}', not recording.") @buffer.note_dropped end
note_dropped_events(total_count, dropped_count)
click to toggle source
# File lib/new_relic/agent/custom_event_aggregator.rb, line 54 def note_dropped_events total_count, dropped_count if dropped_count > 0 NewRelic::Agent.logger.warn("Dropped #{dropped_count} custom events out of #{total_count}.") end end
record_supportability_metrics(total_count, captured_count, dropped_count)
click to toggle source
# File lib/new_relic/agent/custom_event_aggregator.rb, line 60 def record_supportability_metrics total_count, captured_count, dropped_count engine = NewRelic::Agent.instance.stats_engine engine.tl_record_supportability_metric_count("Events/Customer/Seen" , total_count) engine.tl_record_supportability_metric_count("Events/Customer/Sent" , captured_count) engine.tl_record_supportability_metric_count("Events/Customer/Dropped", dropped_count) end