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

fix(logrus-hook): Don't throw error if sentry event is dropped #579

Closed
wants to merge 1 commit into from
Closed

fix(logrus-hook): Don't throw error if sentry event is dropped #579

wants to merge 1 commit into from

Conversation

hnicke
Copy link

@hnicke hnicke commented Feb 10, 2023

When using the logrus hook to send logrus logs to sentry, an error was logged when the corresponding sentry event is being dropped client-side. This happens for example when using the BeforeSend event transformation function.

This should not be considered an error.

Resolves #578

When using the logrus hook to send logrus logs to sentry, an error was
logged when the corresponding sentry event is being dropped client-side.
This happens for example when using the `BeforeSend` event transformation function.

This should not be considered an error.

Resolves #578
@@ -121,7 +121,6 @@ func (h *Hook) Fire(entry *logrus.Entry) error {
if h.fallback != nil {
return h.fallback(entry)
}
return errors.New("failed to send to sentry")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm questioning the usefulness of handling the return value of CaptureEvent altogether. By default, the ID is always returned, even if the HTTPTransport does not successfully submit the event to Sentry, as we do not have a back channel to the main thread. So this only applies when using the HTTPSyncTransport.

@codecov
Copy link

codecov bot commented Feb 13, 2023

Codecov Report

Base: 79.14% // Head: 79.16% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (44e416b) compared to base (f03b31a).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #579      +/-   ##
==========================================
+ Coverage   79.14%   79.16%   +0.02%     
==========================================
  Files          38       38              
  Lines        3856     3855       -1     
==========================================
  Hits         3052     3052              
+ Misses        703      702       -1     
  Partials      101      101              
Impacted Files Coverage Δ
logrus/logrusentry.go 73.45% <ø> (+0.64%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@hnicke
Copy link
Author

hnicke commented Feb 15, 2023

I have figured out that the error can be suppressed by setting a fallback:

hook.SetFallback(func(entry *log.Entry) error {
	return nil
})

Given this solution the PR is not needed anymore.

@hnicke hnicke closed this Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logrus hook prints error if event has been dropped
2 participants