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.
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:
foo.go
logs an error, and I haveInAppPrefix
set togithub.com/myproject
, the culprit is the relevant log methodlogwrapper/wrapper.go
.foo.go
logs an error, and I haveInAppPrefix
set togithub.com/myproject/myapp
, the culprit is the relevant log method inlogrus
(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 theStackTraceConfiguration
, becauseErrorf
andError
differ by 1 stack frame, sinceErrorf
callsError
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:StackTraceConfiguration
forExcludeFromStacktrace
prefixesStackTraceConfiguration
for a customStackTracer
interface that provides the stacktrace external tologrus_sentry
. We don't usepkg.Error
so we don't really benefit from all that logic.