def continue_transaction(txn_id, group_name, category = :requests, union_station_key = nil)
if !@server_address
return Log.new
elsif !txn_id || txn_id.empty?
raise ArgumentError, "Transaction ID may not be empty"
end
Lock.new(@mutex).synchronize do |lock|
Lock.new(@shared_data.mutex).synchronize do |shared_data_lock|
try_count = 0
if current_time >= @next_reconnect_time
while try_count < @max_connect_tries
begin
connect if !connected?
@shared_data.client.write("openTransaction",
txn_id, group_name, "", category,
AnalyticsLogger.timestamp_string,
union_station_key,
true)
return Log.new(@shared_data, txn_id)
rescue Errno::ENOENT, *NETWORK_ERRORS
try_count += 1
disconnect(true)
shared_data_lock.reset(@shared_data.mutex, false)
lock.unlock
sleep RETRY_SLEEP if try_count < @max_connect_tries
lock.lock
shared_data_lock.lock
rescue Exception => e
disconnect
raise e
end
end
DebugLogging.warn("Cannot connect to the logging agent (#{@server_address}); " +
"retrying in #{@reconnect_timeout} second(s).")
@next_reconnect_time = current_time + @reconnect_timeout
end
return Log.new
end
end
end