Skip to content

Commit

Permalink
Support sentry-ruby in exception handlers by implementing Barbeque::E…
Browse files Browse the repository at this point in the history
…xceptionHandler::Sentry
  • Loading branch information
s4ichi committed May 19, 2022
1 parent 5de51f1 commit 4525d72
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 4525d72

Please sign in to comment.