Skip to content

Commit

Permalink
add app version to sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
sxwebdev committed Mar 9, 2024
1 parent c2fe5a9 commit 4ad4987
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/sentry/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,17 @@ func InitSentryForZap(cfg Config, opts ...Option) (zap.Option, error) {
if entry.Level >= zapcore.ErrorLevel {
e := sentry.NewEvent()
e.Timestamp = entry.Time
e.Message = entry.Message
e.Message = fmt.Sprintf(
"%s\n\n%s, Line No: %d :: stack:\n%s",
entry.Message,
entry.Caller.File,
entry.Caller.Line,
entry.Stack,
)
e.Level = sentry.Level(entry.Level.String())
e.Logger = entry.LoggerName
e.Environment = cfg.Environment
e.Release = cfg.appVersion
sentry.CaptureEvent(e)
}

Expand All @@ -53,7 +60,7 @@ func InitSentryForZap(cfg Config, opts ...Option) (zap.Option, error) {
//
// By default, the timeout is 2 seconds
func Flush(timeout time.Duration) bool {
if timeout == 0 {
if timeout < time.Second*2 {
timeout = 2 * time.Second
}

Expand Down

0 comments on commit 4ad4987

Please sign in to comment.