-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
WIP: Sentry logger #184
Closed
Closed
WIP: Sentry logger #184
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
c7953cc
Glide up with raven deps
82a3cff
Add sentry logger
57f1818
Remove redundant string check
e64024a
Dot all the things, remove With- prefix from most things
f154efd
Fix out of date comment
6a67edb
Handle panic and fatal loggers correctly
ed2ea44
Remove debug level from the conversion map
fd62c4d
Assert that extra doesn't change after logging a message
546d634
Move vars to const. Add debug level to the sentry map
f4b7ce9
Spelling
01a10c6
Fix import order
0a9c6ef
Un-export capturers and remove option to make a custom one
34aca81
Temporarily work around .With mutability
96106d0
Implement DFatal
7ddf402
Un-indent large portion of a function by reversing logic
b46fa1c
Pin raven-go to a new version
f34531d
Add full test with mock local sentry server
cd44bfa
Fix the lock file
bfb2507
Move to the new DPanic interface
8c016da
Remove t from withTestSentry func
b6f7b71
Better handling of turning off traces
97cf03d
Split trace configs into own options
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
Split trace configs into own options
Cover Panic functions on the logger
- Loading branch information
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ import ( | |
const ( | ||
_platform = "go" | ||
_traceContextLines = 3 | ||
_traceSkipFrames = 3 | ||
_traceSkipFrames = 2 | ||
) | ||
|
||
var _zapToRavenMap = map[zap.Level]raven.Severity{ | ||
|
@@ -91,30 +91,44 @@ func New(dsn string, options ...Option) (*Logger, error) { | |
return l, nil | ||
} | ||
|
||
// MinLevel provides a minimum level threshold, above which Sentry packets will be triggered | ||
// MinLevel provides a minimum level threshold. | ||
// All log messages above the set level are sent to Sentry. | ||
func MinLevel(level zap.Level) Option { | ||
return func(l *Logger) { | ||
l.minLevel = level | ||
} | ||
} | ||
|
||
// DisableTraces allows to turn off Stacktrace for sentry packets | ||
// DisableTraces allows to turn off Stacktrace for sentry packets. | ||
func DisableTraces() Option { | ||
return func(l *Logger) { | ||
l.traceEnabled = false | ||
} | ||
} | ||
|
||
// TraceCfg allows to change the number of skipped frames, number of context lines and | ||
// list of go prefixes that are considered "in-app", i.e. "github.com/uber-go/zap". | ||
func TraceCfg(skip, context int, prefixes []string) Option { | ||
// TraceContextLines sets how many lines of code (in on direction) are sent | ||
// with the Sentry packet. | ||
func TraceContextLines(lines int) Option { | ||
return func(l *Logger) { | ||
l.traceContextLines = lines | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the default is to enable tracing, consider making this |
||
|
||
// TraceAppPrefixes sets a list of go import prefixes that are considered "in app". | ||
func TraceAppPrefixes(prefixes []string) Option { | ||
return func(l *Logger) { | ||
l.traceSkipFrames = skip | ||
l.traceContextLines = context | ||
l.traceAppPrefixes = prefixes | ||
} | ||
} | ||
|
||
// TraceSkipFrames sets how many stacktrace frames to skip when sending a | ||
// sentry packet. This is very useful when helper functions are involved. | ||
func TraceSkipFrames(skip int) Option { | ||
return func(l *Logger) { | ||
l.traceSkipFrames = skip | ||
} | ||
} | ||
|
||
// Extra stores additional information for each Sentry event. | ||
func Extra(extra map[string]interface{}) Option { | ||
return func(l *Logger) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a
var _ zap.Logger = &Logger{}
here; that way the compiler ensures thatsentry.Logger
implementszap.Logger
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not strictly necessary, as other places return
sentry.Logger
forzap.Logger
return type, so it's impossible to compile without satisfyingzap.Logger
.