setry transaction

This commit is contained in:
Ruidy 2024-03-11 20:59:15 +01:00
parent 4ae233f9a3
commit e100f50def
No known key found for this signature in database
GPG key ID: E00F51288CB857CC

View file

@ -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 {