Module: NewRelic::Agent::AgentHelpers::Transmit

Included in:
NewRelic::Agent::Agent
Defined in:
lib/new_relic/agent/agent_helpers/transmit.rb

Constant Summary collapse

TRANSACTION_EVENT =
'TransactionEvent'.freeze
CUSTOM_EVENT =
'CustomEvent'.freeze
ERROR_EVENT =
'ErrorEvent'.freeze
SPAN_EVENT =
'SpanEvent'.freeze
LOG_EVENT =
'LogEvent'.freeze

Instance Method Summary collapse

Instance Method Details

#transmit_analytic_event_dataObject



10
11
12
# File 'lib/new_relic/agent/agent_helpers/transmit.rb', line 10

def transmit_analytic_event_data
  transmit_single_data_type(:harvest_and_send_analytic_event_data, TRANSACTION_EVENT)
end

#transmit_custom_event_dataObject



15
16
17
# File 'lib/new_relic/agent/agent_helpers/transmit.rb', line 15

def transmit_custom_event_data
  transmit_single_data_type(:harvest_and_send_custom_event_data, CUSTOM_EVENT)
end

#transmit_dataObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/new_relic/agent/agent_helpers/transmit.rb', line 48

def transmit_data
  now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  ::NewRelic::Agent.logger.debug('Sending data to New Relic Service')

  @events.notify(:before_harvest)
  @service.session do # use http keep-alive
    harvest_and_send_data_types

    check_for_and_handle_agent_commands
    harvest_and_send_for_agent_commands
  end
ensure
  NewRelic::Agent::Database.close_connections
  duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - now
  NewRelic::Agent.record_metric('Supportability/Harvest', duration)
end

#transmit_data_typesObject



65
66
67
68
69
70
71
72
# File 'lib/new_relic/agent/agent_helpers/transmit.rb', line 65

def transmit_data_types
  transmit_data
  transmit_analytic_event_data
  transmit_custom_event_data
  transmit_error_event_data
  transmit_span_event_data
  transmit_log_event_data
end

#transmit_error_event_dataObject



20
21
22
# File 'lib/new_relic/agent/agent_helpers/transmit.rb', line 20

def transmit_error_event_data
  transmit_single_data_type(:harvest_and_send_error_event_data, ERROR_EVENT)
end

#transmit_log_event_dataObject



30
31
32
# File 'lib/new_relic/agent/agent_helpers/transmit.rb', line 30

def transmit_log_event_data
  transmit_single_data_type(:harvest_and_send_log_event_data, LOG_EVENT)
end

#transmit_single_data_type(harvest_method, supportability_name) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/new_relic/agent/agent_helpers/transmit.rb', line 34

def transmit_single_data_type(harvest_method, supportability_name)
  now = Process.clock_gettime(Process::CLOCK_MONOTONIC)

  msg = "Sending #{supportability_name} data to New Relic Service"
  ::NewRelic::Agent.logger.debug(msg)

  @service.session do # use http keep-alive
    self.send(harvest_method)
  end
ensure
  duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - now
  NewRelic::Agent.record_metric("Supportability/#{supportability_name}Harvest", duration)
end

#transmit_span_event_dataObject



25
26
27
# File 'lib/new_relic/agent/agent_helpers/transmit.rb', line 25

def transmit_span_event_data
  transmit_single_data_type(:harvest_and_send_span_event_data, SPAN_EVENT)
end