class OneApm::Collector::ForkedProcessService

Attributes

agent_id[RW]
buffer[R]
channel_id[R]
collector[RW]
pipe[R]
request_timeout[RW]

Public Class Methods

new(channel_id) click to toggle source
# 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

Public Instance Methods

analytic_event_data(events) click to toggle source
# 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) click to toggle source
# File lib/one_apm/collector/support/forked_process_service.rb, line 20
def connect(config)
  nil
end
custom_event_data(events) click to toggle source
# 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) click to toggle source
# 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_commands() click to toggle source
# File lib/one_apm/collector/support/forked_process_service.rb, line 24
def get_agent_commands
  []
end
metric_data(unsent_timeslice_data) click to toggle source
# 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_cache() click to toggle source
# 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
session() { || ... } click to toggle source

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.

# File lib/one_apm/collector/support/forked_process_service.rb, line 60
def session
  yield
end
shutdown(time) click to toggle source
# File lib/one_apm/collector/support/forked_process_service.rb, line 53
def shutdown(time)
  @pipe.close if @pipe
end
sql_trace_data(sql) click to toggle source
# 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) click to toggle source
# 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

Private Instance Methods

marshal_payload(data) click to toggle source
# File lib/one_apm/collector/support/forked_process_service.rb, line 70
def marshal_payload(data)
  OneApm::LanguageSupport.with_cautious_gc do
    Marshal.dump(data)
  end
end
write_to_pipe(endpoint, data) click to toggle source
# File lib/one_apm/collector/support/forked_process_service.rb, line 76
def write_to_pipe(endpoint, data)
  @pipe.write(marshal_payload([endpoint, data])) if @pipe
end