class StackifyRubyAPM::LogClient
This class will handle the writing of messages through a logfile. @api private
Public Class Methods
new(config)
click to toggle source
# File lib/stackify_apm/transport/log_client.rb, line 12 def initialize(config) @config = config @transaction_serializers = Serializers::Transactions.new(@config) end
Public Instance Methods
post(transactions = [])
click to toggle source
This method will build an Array
of Transactions in a json format. It will accept Array
of transactions.
# File lib/stackify_apm/transport/log_client.rb, line 19 def post(transactions = []) # convert transactions to json json_traces = [] transactions.each do |transaction| # convert transaction to json json_transaction = @transaction_serializers.build_json(@config, transaction).to_json # add to json traces array json_traces.push(json_transaction) end current_datetime = Time.now.utc.strftime('%Y-%m-%d, %H:%M:%S.%6N') return unless ENV['STACKIFY_RUBY_ENV'] != 'rspec' json_traces.each do |json_trace| @config.tracer_logger.<<("#{current_datetime} > #{json_trace} \n") end debug '[LogClient] post() Successfully write to logfile.' if ENV['STACKIFY_TRANSPORT_LOG_LEVEL'] == '0' rescue StandardError => e debug "[LogClient] post() exception: #{e.inspect}" end