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

Logging wrapper gets caught as culprit #59

Open
mightyguava opened this issue Mar 8, 2018 · 0 comments
Open

Logging wrapper gets caught as culprit #59

mightyguava opened this issue Mar 8, 2018 · 0 comments
Assignees

Comments

@mightyguava
Copy link
Contributor

mightyguava commented Mar 8, 2018

I'm using a wrapper for the logrus library to add file/line and just as an internal abstraction for the logging library.

After starting to use the wrapper, I'm seeing that when an error is logged by library code, the culprit is identified as a frame in the log wrapper, because I have the InAppPrefix set to the top-level package path for my project.

I think an example serves best here:

github.com/myproject/
  myapp/
     main.go
  mylib/
    foo.go <= This logs an exception
  logwrapper/
    wrapper.go
  • If foo.go logs an error, and I have InAppPrefix set to github.com/myproject, the culprit is the relevant log method logwrapper/wrapper.go.
  • If foo.go logs an error, and I have InAppPrefix set to github.com/myproject/myapp, the culprit is the relevant log method in logrus (I'm not seeing any client code setting culprit here, so I guess the server is picking it, and none of the packages in the stacktrace belong to the InAppPrefix).

I can't just set Skip to the right number on the StackTraceConfiguration, because Errorf and Error differ by 1 stack frame, since Errorf calls Error

Do you have any thoughts on how to get the culprit become the line that logs in foo.go? The options that I see are:

  • Adding an option to StackTraceConfiguration for ExcludeFromStacktrace prefixes
  • Adding an option to StackTraceConfiguration for a custom StackTracer interface that provides the stacktrace external to logrus_sentry. We don't use pkg.Error so we don't really benefit from all that logic.
@evalphobia evalphobia self-assigned this Mar 12, 2018
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

No branches or pull requests

2 participants