Skip to content

Commit

Permalink
add: sample rate in sentry init
Browse files Browse the repository at this point in the history
  • Loading branch information
sreeram-narayanan authored and vipul-sharma20 committed Oct 17, 2022
1 parent 869b32e commit 44efb0d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion surveillance/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"net/http"
"os"
"strconv"

"github.com/Vernacular-ai/vcore/errors"
"github.com/Vernacular-ai/vcore/log"
Expand All @@ -23,6 +24,9 @@ type Sentry struct {

func InitSentry(release string) (client *Sentry) {
dsn := os.Getenv("SENTRY_DSN")

sampleRate, _ := strconv.ParseFloat(os.Getenv("SENTRY_SAMPLING"), 64)

if release == "" {
release = os.Getenv("SENTRY_RELEASE")
}
Expand All @@ -35,7 +39,8 @@ func InitSentry(release string) (client *Sentry) {

// Enable debugging to check connectivity
//Debug: true,
Release: release,
Release: release,
SampleRate: sampleRate,

Environment: os.Getenv("ENVIRONMENT"),
}); err != nil {
Expand Down
8 changes: 8 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,11 @@ func ConvertInterfaceToString(val interface{}) (string, bool) {
stringValue, ok := val.(string)
return stringValue, ok
}

// GetEnv - Return the fallback env if not present
func GetEnv(key, fallback string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
return fallback
}

0 comments on commit 44efb0d

Please sign in to comment.