Class: NewRelic::Agent::NewRelicService

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/agent/new_relic_service.rb

Constant Summary collapse

PROTOCOL_VERSION =

Specifies the version of the agent’s communication protocol with the NewRelic hosted site.

8

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(license_key = control.license_key, collector = control.server) ⇒ NewRelicService

Returns a new instance of NewRelicService.



20
21
22
23
24
# File 'lib/new_relic/agent/new_relic_service.rb', line 20

def initialize(license_key=control.license_key, collector=control.server)
  @license_key = license_key
  @collector = collector
  @request_timeout = NewRelic::Control.instance.fetch('timeout', 2 * 60)
end

Instance Attribute Details

#agent_idObject

Returns the value of attribute agent_id.



18
19
20
# File 'lib/new_relic/agent/new_relic_service.rb', line 18

def agent_id
  @agent_id
end

#collectorObject (readonly)

Returns the value of attribute collector.



17
18
19
# File 'lib/new_relic/agent/new_relic_service.rb', line 17

def collector
  @collector
end

#request_timeoutObject

14105: v8 (tag 2.10.3) (no v7) 10379: v6 (not tagged) 4078: v5 (tag 2.5.4) 2292: v4 (tag 2.3.6) 1754: v3 (tag 2.3.0) 534: v2 (shows up in 2.1.0, our first tag)



16
17
18
# File 'lib/new_relic/agent/new_relic_service.rb', line 16

def request_timeout
  @request_timeout
end

Instance Method Details

#connect(settings = {}) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/new_relic/agent/new_relic_service.rb', line 26

def connect(settings={})
  if host = get_redirect_host
    @collector = NewRelic::Control.instance.server_from_host(host)
  end
  response = invoke_remote(:connect, settings)
  @agent_id = response['agent_run_id']
  response
end

#error_data(unsent_errors) ⇒ Object



48
49
50
# File 'lib/new_relic/agent/new_relic_service.rb', line 48

def error_data(unsent_errors)
  invoke_remote(:error_data, @agent_id, unsent_errors)
end

#get_redirect_hostObject



35
36
37
# File 'lib/new_relic/agent/new_relic_service.rb', line 35

def get_redirect_host
  invoke_remote(:get_redirect_host)
end

#metric_data(last_harvest_time, now, unsent_timeslice_data) ⇒ Object



43
44
45
46
# File 'lib/new_relic/agent/new_relic_service.rb', line 43

def metric_data(last_harvest_time, now, unsent_timeslice_data)
  invoke_remote(:metric_data, @agent_id, last_harvest_time, now,
                unsent_timeslice_data)
end

#shutdown(time) ⇒ Object



39
40
41
# File 'lib/new_relic/agent/new_relic_service.rb', line 39

def shutdown(time)
  invoke_remote(:shutdown, @agent_id, time) if @agent_id
end

#sql_trace_data(sql_traces) ⇒ Object



56
57
58
# File 'lib/new_relic/agent/new_relic_service.rb', line 56

def sql_trace_data(sql_traces)
  invoke_remote(:sql_trace_data, sql_traces)
end

#transaction_sample_data(traces) ⇒ Object



52
53
54
# File 'lib/new_relic/agent/new_relic_service.rb', line 52

def transaction_sample_data(traces)
  invoke_remote(:transaction_sample_data, @agent_id, traces)
end