Class: StackifyRubyAPM::TraceLogger Private
- Inherits:
-
Object
- Object
- StackifyRubyAPM::TraceLogger
- Includes:
- Log
- Defined in:
- lib/stackify_apm/trace_logger.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.
Constant Summary
Constants included from Log
Instance Attribute Summary collapse
- #trace_file_counter ⇒ Object private
Instance Method Summary collapse
-
#initialize(config) ⇒ TraceLogger
constructor
private
A new instance of TraceLogger.
- #post(transactions = []) ⇒ Object private
Methods included from Log
#debug, #error, #fatal, #info, #log, #warn
Constructor Details
#initialize(config) ⇒ TraceLogger
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 TraceLogger.
13 14 15 16 17 |
# File 'lib/stackify_apm/trace_logger.rb', line 13 def initialize(config) @config = config @trace_file_counter = 0 @transaction_serializers = Serializers::Transactions.new(config) end |
Instance Attribute Details
#trace_file_counter ⇒ Object
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.
19 20 21 |
# File 'lib/stackify_apm/trace_logger.rb', line 19 def trace_file_counter @trace_file_counter end |
Instance Method Details
#post(transactions = []) ⇒ Object
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.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/stackify_apm/trace_logger.rb', line 21 def post(transactions = []) # convert transactions to json json_traces = [] transactions.each do |transaction| # convert transaction to json json_transaction = @transaction_serializers.build(@config, transaction).to_json # add to json traces array json_traces.push(json_transaction) end date_now = Time.now current_datetime = date_now.strftime('%Y-%m-%d, %H:%M:%S.%6N') return unless ENV['STACKIFY_RUBY_ENV'] != 'rspec' json_traces.each do |json_trace| update_json = current_datetime + ' > ' + json_trace + "\n" @config.tracer_logger.<<(update_json) end end |