Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHubFromContext ¶
GetHubFromContext retrieves attached *sentry.Hub instance from echo.Context.
func GetSpanFromContext ¶
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)
})
func New ¶
func New(options Options) echo.MiddlewareFunc
New returns a function that satisfies echo.HandlerFunc interface It can be used with Use() methods.
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 that 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.