Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHubFromContext ¶
func GetHubFromContext(ctx echo.Context) *sentry.Hub
GetHubFromContext retrieves attached *sentry.Hub instance from echo.Context.
func GetSpanFromContext ¶ added in v0.28.0
func GetSpanFromContext(ctx echo.Context) *sentry.Span
GetSpanFromContext retrieves attached *sentry.Span instance from echo.Context. If there is no transaction on echo.Context, it will return nil.
Example ¶
router := echo.New()
router.Use(sentryecho.New(sentryecho.Options{}))
router.GET("/", func(c echo.Context) error {
expensiveThing := func(ctx context.Context) error {
span := sentry.StartTransaction(ctx, "expensive_thing")
defer span.Finish()
// do resource intensive thing
return nil
}
// Acquire transaction on current hub that's created by the SDK.
// Be careful, it might be a nil value if you didn't set up sentryecho middleware.
sentrySpan := sentryecho.GetSpanFromContext(c)
// Pass in the `.Context()` method from `*sentry.Span` struct.
// The `context.Context` instance inherits the context from `echo.Context`.
err := expensiveThing(sentrySpan.Context())
if err != nil {
return err
}
return c.NoContent(http.StatusOK)
})
Types ¶
type Options ¶
type Options struct {
// Repanic configures whether Sentry should repanic after recovery, in most cases it should be set to true,
// as echo includes its own Recover middleware what handles http responses.
Repanic bool
// WaitForDelivery configures whether you want to block the request before moving forward with the response.
// Because Echo's Recover handler doesn't restart the application,
// it's safe to either skip this option or set it to false.
WaitForDelivery bool
// Timeout for the event delivery requests.
Timeout time.Duration
}
Click to show internal directories.
Click to hide internal directories.