Skip to content

Instantly share code, notes, and snippets.

@Kalimaha
Created October 5, 2016 23:02
Show Gist options
  • Select an option

  • Save Kalimaha/b123279a4d094ff876dbaec4cadf3582 to your computer and use it in GitHub Desktop.

Select an option

Save Kalimaha/b123279a4d094ff876dbaec4cadf3582 to your computer and use it in GitHub Desktop.
Log the Transaction and Request ID across multiple microservices
# frozen_string_literal: true
require 'docker_logger'
module Utils
class Logger
def self.instance
RequestIdentityLogger
end
end
class RequestIdentityLogger
def self.instance
@logger ||= DockerLogger::Logger.get('Proposals')
end
def self.common(method_name, message)
instance.send(method_name, transactionid.merge(message: message).to_json)
end
def self.error(message)
common(:error, message)
end
def self.info(message)
common(:info, message)
end
def self.warn(message)
common(:warn, message)
end
def self.transactionid
{
transactionId: RequestIdentity.transaction_id,
requestId: RequestIdentity.request_id
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment