Skip to content

Commit

Permalink
Merge pull request #92 from s4ichi/sentry-ruby-support
Browse files Browse the repository at this point in the history
Support sentry-ruby in exception handlers by implementing Barbeque::ExceptionHandler::Sentry
  • Loading branch information
s4ichi authored May 20, 2022
2 parents 5de51f1 + 4525d72 commit 8da0c07
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/barbeque/exception_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,32 @@ def handle_exception(e)
::Raven.capture_exception(e)
end
end

class Sentry
def initialize
::Sentry.get_current_hub.push_scope
end

def clear_context
::Sentry.get_current_hub.pop_scope
::Sentry.get_current_hub.push_scope
end

# @param [String] message_id
# @param [String, nil] message_type
def set_message_context(message_id, message_type)
::Sentry.configure_scope do |scope|
scope.set_tags(
message_id: message_id,
message_type: message_type
)
end
end

# @param [Exception] e
def handle_exception(e)
::Sentry.capture_exception(e)
end
end
end
end

0 comments on commit 8da0c07

Please sign in to comment.