diff --git a/internal/server/handle_bookings.go b/internal/server/handle_bookings.go index b246025..7209a73 100644 --- a/internal/server/handle_bookings.go +++ b/internal/server/handle_bookings.go @@ -7,6 +7,7 @@ import ( "time" "github.com/a-h/templ" + "github.com/getsentry/sentry-go" "github.com/labstack/echo/v4" "github.com/labstack/gommon/log" u "github.com/rjNemo/underscore" @@ -20,6 +21,27 @@ import ( func handleListBookingPage(bs *booking.Service, hc *config.Host) echo.HandlerFunc { return func(c echo.Context) error { + ctx := c.Request().Context() + hub := sentry.GetHubFromContext(ctx) + if hub == nil { + // Check the concurrency guide for more details: https://docs.sentry.io/platforms/go/concurrency/ + hub = sentry.CurrentHub().Clone() + ctx = sentry.SetHubOnContext(ctx, hub) + } + + options := []sentry.SpanOption{ + // Set the OP based on values from https://develop.sentry.dev/sdk/performance/span-operations/ + sentry.WithOpName("http.server"), + sentry.ContinueFromRequest(c.Request()), + sentry.WithTransactionSource(sentry.SourceURL), + } + + transaction := sentry.StartTransaction(ctx, + fmt.Sprintf("%s %s", c.Request().Method, c.Request().URL.Path), + options..., + ) + defer transaction.Finish() + bookings := bs.All() bvm := u.Map(bookings, func(b *booking.Line) *view.ListBookingsViewModel {