Skip to content

Instantly share code, notes, and snippets.

@prdanelli
Created December 2, 2022 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prdanelli/7129a5281ec2b82bb03de59994b5c769 to your computer and use it in GitHub Desktop.
Save prdanelli/7129a5281ec2b82bb03de59994b5c769 to your computer and use it in GitHub Desktop.
Log Extra data to Sentry
def my_method
# ...
rescue NoMethodError => e
Sentry.with_scope do |scope|
scope.set_tags(foo: "bar") # <= Searchable tags
scope.set_context('Model Attributes', @local_instance_variable.attributes) # <= Logs extra hash of data
Sentry.capture_message("A test message") # <= Your custom message
Sentry.capture_error(e) # <= Log the error
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment