From e100f50defb4008879acacf097272aefbd88702c Mon Sep 17 00:00:00 2001 From: Ruidy Date: Mon, 11 Mar 2024 20:59:15 +0100 Subject: [PATCH] setry transaction --- internal/server/handle_bookings.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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 {