Skip to content

Commit 3d3f598

Browse files
committed
add sentry reporting for panics + auth issues
1 parent f543127 commit 3d3f598

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

config/auth.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/pkg/browser"
1212
"golang.org/x/exp/slog"
13+
"github.com/getsentry/sentry-go"
1314

1415
"github.com/apoxy-dev/apoxy-cli/rest"
1516
"github.com/apoxy-dev/apoxy-cli/web"
@@ -103,6 +104,7 @@ func (a *Authenticator) launchServer() int {
103104
}()
104105
if err := a.awaitHealthy(port); err != nil {
105106
slog.Error(fmt.Sprintf("Error starting server: %v", err))
107+
sentry.CaptureMessage("auth redirect server failed to start")
106108
}
107109
return port
108110
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ require (
2828
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
2929
github.com/davecgh/go-spew v1.1.1 // indirect
3030
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
31+
github.com/getsentry/sentry-go v0.26.0 // indirect
3132
github.com/go-logr/logr v1.2.4 // indirect
3233
github.com/go-openapi/jsonpointer v0.19.6 // indirect
3334
github.com/go-openapi/jsonreference v0.20.2 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBd
4343
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
4444
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
4545
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
46+
github.com/getsentry/sentry-go v0.26.0 h1:IX3++sF6/4B5JcevhdZfdKIHfyvMmAq/UnqcyT2H6mA=
47+
github.com/getsentry/sentry-go v0.26.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
4648
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
4749
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
4850
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=

main.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,32 @@ limitations under the License.
1515
*/
1616
package main
1717

18-
import "github.com/apoxy-dev/apoxy-cli/cmd"
18+
import (
19+
"log"
20+
"time"
21+
22+
"github.com/getsentry/sentry-go"
23+
24+
"github.com/apoxy-dev/apoxy-cli/cmd"
25+
)
1926

2027
func main() {
28+
// We send errors to Sentry to ensure the best possible experience for our users.
29+
err := sentry.Init(sentry.ClientOptions{
30+
Dsn: "https://4da486e8bfc297ebd07dea8a1419f5da@o4506619284815872.ingest.sentry.io/4506619287306240",
31+
TracesSampleRate: 1.0,
32+
})
33+
if err != nil {
34+
log.Fatalf("sentry.Init: %s", err)
35+
}
36+
defer func() {
37+
if err := recover(); err != nil {
38+
sentry.CurrentHub().Recover(err)
39+
sentry.Flush(5 * time.Second)
40+
log.Printf("panic: %v", err)
41+
}
42+
}()
43+
defer sentry.Flush(5 * time.Second)
44+
2145
cmd.Execute()
2246
}

0 commit comments

Comments
 (0)