|
|
@@ -2,6 +2,7 @@ package alerter
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
+ "fmt"
|
|
|
|
|
|
"github.com/getsentry/sentry-go"
|
|
|
)
|
|
|
@@ -14,11 +15,12 @@ func noIntegrations(ints []sentry.Integration) []sentry.Integration {
|
|
|
return []sentry.Integration{}
|
|
|
}
|
|
|
|
|
|
-func NewSentryAlerter(sentryDSN string) (*SentryAlerter, error) {
|
|
|
+func NewSentryAlerter(sentryDSN, sentryEnv string) (*SentryAlerter, error) {
|
|
|
sentryClient, err := sentry.NewClient(sentry.ClientOptions{
|
|
|
Dsn: sentryDSN,
|
|
|
AttachStacktrace: true,
|
|
|
Integrations: noIntegrations,
|
|
|
+ Environment: sentryEnv,
|
|
|
})
|
|
|
|
|
|
if err != nil {
|
|
|
@@ -33,7 +35,9 @@ func NewSentryAlerter(sentryDSN string) (*SentryAlerter, error) {
|
|
|
func (s *SentryAlerter) SendAlert(ctx context.Context, err error, data map[string]interface{}) {
|
|
|
scope := sentry.NewScope()
|
|
|
|
|
|
- scope.SetExtras(data)
|
|
|
+ for key, val := range data {
|
|
|
+ scope.SetTag(key, fmt.Sprintf("%v", val))
|
|
|
+ }
|
|
|
|
|
|
s.client.CaptureException(
|
|
|
err,
|