mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
chore: exclude static endpoints from sentry tracing
chore: include user info to sentry tracing again
This commit is contained in:
@ -100,6 +100,13 @@ func (l *SentryWrapperLogger) log(msg string, level sentry.Level) {
|
||||
sentry.CaptureEvent(event)
|
||||
}
|
||||
|
||||
var excludedRoutes = []string{
|
||||
"GET /assets",
|
||||
"GET /api/health",
|
||||
"GET /swagger-ui",
|
||||
"GET /docs",
|
||||
}
|
||||
|
||||
func initSentry(config sentryConfig, debug bool) {
|
||||
if err := sentry.Init(sentry.ClientOptions{
|
||||
Dsn: config.Dsn,
|
||||
@ -112,8 +119,10 @@ func initSentry(config sentryConfig, debug bool) {
|
||||
hub := sentry.GetHubFromContext(ctx.Span.Context())
|
||||
txName := hub.Scope().Transaction()
|
||||
|
||||
if strings.HasPrefix(txName, "GET /assets") || strings.HasPrefix(txName, "GET /api/health") {
|
||||
return sentry.SampledFalse
|
||||
for _, ex := range excludedRoutes {
|
||||
if strings.HasPrefix(txName, ex) {
|
||||
return sentry.SampledFalse
|
||||
}
|
||||
}
|
||||
if txName == "POST /api/heartbeat" {
|
||||
return sentry.UniformTracesSampler(config.SampleRateHeartbeats).Sample(ctx)
|
||||
|
Reference in New Issue
Block a user