Skip to content

Commit

Permalink
Allow to specify sentry envionment and release.
Browse files Browse the repository at this point in the history
  • Loading branch information
imperiuse committed Nov 16, 2023
1 parent ae07d22 commit 4cc3673
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,21 @@ func main() {
splitLogs := flag.Bool("split-logs", false, "split log output into stdout/stderr")
passthroughLogs := flag.Bool("passthrough-logs", false, "passthrough logs from commands, do not wrap them in Supercronic logging")
sentry := flag.String("sentry-dsn", "", "enable Sentry error logging, using provided DSN")
sentryEnvironmentFlag := flag.String("sentry-environment", "", "specify the application's environment for Sentry error reporting.")
sentryReleaseFlag := flag.String("sentry-release", "", "specify the application's release version for Sentry error reporting")
sentryAlias := flag.String("sentryDsn", "", "alias for sentry-dsn")
overlapping := flag.Bool("overlapping", false, "enable tasks overlapping")
flag.Parse()

var sentryDsn string
var (
sentryDsn string
sentryEnvironment string
sentryRelease string
)

sentryDsn = os.Getenv("SENTRY_DSN")
sentryEnvironment = os.Getenv("SENTRY_ENVIRONMENT")
sentryRelease = os.Getenv("SENTRY_RELEASE")

if *sentryAlias != "" {
sentryDsn = *sentryAlias
Expand All @@ -56,6 +64,14 @@ func main() {
sentryDsn = *sentry
}

if *sentryEnvironmentFlag != "" {
sentryEnvironment = *sentryEnvironmentFlag
}

if *sentryReleaseFlag != "" {
sentryRelease = *sentryReleaseFlag
}

if *debug {
logrus.SetLevel(logrus.DebugLevel)
}
Expand Down Expand Up @@ -100,6 +116,14 @@ func main() {
sentryHook = sh
}

if sentryEnvironment != "" {
sh.SetEnvironment(sentryEnvironment)
}

if sentryRelease != "" {
sh.SetRelease(sentryRelease)
}

if sentryHook != nil {
logrus.StandardLogger().AddHook(sentryHook)
}
Expand All @@ -120,7 +144,7 @@ func main() {
}()
}

for true {
for {
promMetrics.Reset()

logrus.Infof("read crontab: %s", crontabFileName)
Expand Down

0 comments on commit 4cc3673

Please sign in to comment.