Class: OneApm::Collector::ForkedProcessService

Inherits:
Object
  • Object
show all
Defined in:
lib/one_apm/collector/support/forked_process_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel_id) ⇒ ForkedProcessService

Returns a new instance of ForkedProcessService.



9
10
11
12
13
14
15
16
17
18
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 9

def initialize(channel_id)
  @channel_id = channel_id
  @collector = OneApm::Support::Server.new(:name => 'parent', :port => 0)
  @pipe = OneApm::Support::ForkedProcessChannel.channels[@channel_id]
  if @pipe && @pipe.parent_pid != $$
    @pipe.after_fork_in_child
  else
    OneApm::Manager.logger.error("No communication channel to parent process.")
  end
end

Instance Attribute Details

#agent_idObject

Returns the value of attribute agent_id.



7
8
9
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 7

def agent_id
  @agent_id
end

#bufferObject (readonly)

Returns the value of attribute buffer.



6
7
8
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 6

def buffer
  @buffer
end

#channel_idObject (readonly)

Returns the value of attribute channel_id.



6
7
8
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 6

def channel_id
  @channel_id
end

#collectorObject

Returns the value of attribute collector.



7
8
9
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 7

def collector
  @collector
end

#pipeObject (readonly)

Returns the value of attribute pipe.



6
7
8
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 6

def pipe
  @pipe
end

#request_timeoutObject

Returns the value of attribute request_timeout.



7
8
9
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 7

def request_timeout
  @request_timeout
end

Instance Method Details

#analytic_event_data(events) ⇒ Object



28
29
30
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 28

def analytic_event_data(events)
  write_to_pipe(:analytic_event_data, events) if events
end

#connect(config) ⇒ Object



20
21
22
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 20

def connect(config)
  nil
end

#custom_event_data(events) ⇒ Object



32
33
34
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 32

def custom_event_data(events)
  write_to_pipe(:custom_event_data, events) if events
end

#error_data(errors) ⇒ Object



45
46
47
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 45

def error_data(errors)
  write_to_pipe(:error_data, errors) if errors
end

#get_agent_commandsObject



24
25
26
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 24

def get_agent_commands
  []
end

#metric_data(unsent_timeslice_data) ⇒ Object



36
37
38
39
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 36

def metric_data(unsent_timeslice_data)
  write_to_pipe(:metric_data, unsent_timeslice_data)
  {}
end

#reset_metric_id_cacheObject



64
65
66
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 64

def reset_metric_id_cache
  # we don't cache metric IDs, so nothing to do
end

#sessionObject

Invokes the block it is passed. This is used to implement HTTP keep-alive in the CollectorService, and is a required interface for any Service class.



60
61
62
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 60

def session
  yield
end

#shutdown(time) ⇒ Object



53
54
55
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 53

def shutdown(time)
  @pipe.close if @pipe
end

#sql_trace_data(sql) ⇒ Object



49
50
51
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 49

def sql_trace_data(sql)
  write_to_pipe(:sql_trace_data, sql) if sql
end

#transaction_sample_data(transactions) ⇒ Object



41
42
43
# File 'lib/one_apm/collector/support/forked_process_service.rb', line 41

def transaction_sample_data(transactions)
  write_to_pipe(:transaction_sample_data, transactions) if transactions
end