Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/#18/Handle error logging for third party issues #19

Merged
merged 5 commits into from
Apr 3, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor refactorings
praWeb committed Apr 3, 2019
commit 3df95fd8d3adc9660fa8e3332870b953261bcc7f
2 changes: 1 addition & 1 deletion lib/shift/circuit_breaker/circuit_handler.rb
Original file line number Diff line number Diff line change
@@ -109,7 +109,7 @@ def handle_exception(exception, fallback)
end

def log_errors(exception)
logger.error(circuit_name: name, state: state, exception: exception, error_message: exception.message, remote_logging_enabled: error_logging_enabled)
logger.error(circuit_name: name, state: state, exception: exception, error_message: exception.message, remote_logging_enabled: error_logging_enabled)
end
end
end
8 changes: 4 additions & 4 deletions lib/shift/circuit_breaker/circuit_logger.rb
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
module Shift
module CircuitBreaker
class CircuitLogger
attr_accessor :logger, :remote_logger, :remote_logging_enabled
attr_accessor :logger, :remote_logger

delegate :debug, :fatal, :info, :warn, :add, :log, to: :logger

@@ -20,7 +20,7 @@ class CircuitLogger
#
# @param [Object] logger - service to handle internal logging
# @param [Object] remote_logger - external error logging service eg. Sentry
def initialize(logger: ::Logger.new(STDOUT), remote_logger: Shift::CircuitBreaker::Adapters::SentryAdapter, remote_logging_enabled: true)
def initialize(logger: ::Logger.new(STDOUT), remote_logger: Shift::CircuitBreaker::Adapters::SentryAdapter)
self.logger = logger
self.remote_logger = remote_logger
self.remote_logging_enabled = remote_logging_enabled
@@ -30,8 +30,8 @@ def initialize(logger: ::Logger.new(STDOUT), remote_logger: Shift::CircuitBreake
def error(context)
message = (ERROR_MESSAGE % context)
logger.error(message)
::NewRelic::Agent.notice_error(context[:exception], { expected: true }) if defined?(NewRelic)
remote_logger.call(message) if remote_logger.respond_to?(:call) && remote_logging_enabled
::NewRelic::Agent.notice_error(context[:exception], expected: true) if defined?(NewRelic)
remote_logger.call(message) if context[:remote_logging_enabled] && remote_logger.respond_to?(:call)
end
end
end
2 changes: 1 addition & 1 deletion lib/shift/circuit_breaker/version.rb
Original file line number Diff line number Diff line change
@@ -2,6 +2,6 @@

module Shift
module CircuitBreaker
VERSION = "0.2.2"
VERSION = "0.2.3"
end
end