Class: StackifyRubyAPM::Worker Private

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/stackify_apm/worker.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: ErrorMsg, FlushMsg, StopMsg

Constant Summary

Constants included from Log

Log::PREFIX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Log

#debug, #error, #fatal, #info, #log, #warn

Constructor Details

#initialize(config, messages, pending_transactions, trace_logger) ⇒ Worker

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Worker.



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/stackify_apm/worker.rb', line 29

def initialize(config, messages, pending_transactions, trace_logger)
  @config = config
  @messages = messages
  @pending_transactions = pending_transactions
  @trace_logger = trace_logger

  @serializers = Struct.new(:transactions, :errors).new(
    Serializers::Transactions.new(config),
    Serializers::Errors.new(config)
  )
end

Instance Attribute Details

#configObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
# File 'lib/stackify_apm/worker.rb', line 41

def config
  @config
end

#messagesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
# File 'lib/stackify_apm/worker.rb', line 41

def messages
  @messages
end

#pending_transactionsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
# File 'lib/stackify_apm/worker.rb', line 41

def pending_transactions
  @pending_transactions
end

Instance Method Details

#run_foreverObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Collects and sends the transactions



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/stackify_apm/worker.rb', line 45

def run_forever
  @timer_task = build_timer_task.execute

  while (msg = messages.pop)
    case msg
    when ErrorMsg
      post_error msg
    when FlushMsg
      collect_and_send_transactions
    when StopMsg
      # empty collected transactions before exiting
      collect_and_send_transactions
      stop!
    end
  end
end