Skip to content

Commit a92cff2

Browse files
committed
PR feedback: check for an empty SentryDSN value
1 parent 0516557 commit a92cff2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lambda/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func handler(ctx context.Context, req events.APIGatewayProxyRequest) (events.API
6060
headers[k] = v[0]
6161
}
6262

63-
if w.Status == http.StatusInternalServerError {
63+
if w.Status == http.StatusInternalServerError && envConfig.SentryDSN != "" {
6464
logger := sentry.NewLogger(ctx)
6565
logger.Error().Emit(string(w.Body))
6666
defer sentry.Flush(2 * time.Second)
@@ -94,6 +94,10 @@ func httpRequestFromProxyRequest(ctx context.Context, req events.APIGatewayProxy
9494
}
9595

9696
func sentryInit() {
97+
if envConfig.SentryDSN == "" {
98+
return
99+
}
100+
97101
if err := sentry.Init(sentry.ClientOptions{
98102
Dsn: envConfig.SentryDSN,
99103
EnableLogs: true,

lambda/main_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import "testing"
4+
5+
func Test_sentryInit(t *testing.T) {
6+
sentryInit()
7+
}

0 commit comments

Comments
 (0)