Documentation ¶
Index ¶
- Constants
- func EchoLogger() echo.Logger
- func Error(ctx context.Context, err error)
- func Flush(ctx ...context.Context)
- func GetHub(ctx ...context.Context) *sentry.Hub
- func HealthcheckFail(optionalBody ...io.Reader)
- func Log(ctx ...context.Context) *zerolog.Logger
- func NewContext(parent ...context.Context) context.Context
- func NewLogger(ctx context.Context, sentryOpts ...zlogsentry.WriterOption) *zerolog.Logger
- func NewLoggerPlain() *zerolog.Logger
- func Recover(err any, repanic bool, ctx ...context.Context)
- func SetHealthchecks(h Healthchecks)
- func SetLogLevel(level string)
- func SetName(name string)
- func SetSentryDSN(dsn string)
- func StartSpan(ctx context.Context, operation string) *sentry.Span
- func WithSentry() echo.MiddlewareFunc
- func WrapClient(c *http.Client, opts ...RoundTripperOption) *http.Client
- func WrapRoundTripper(rt http.RoundTripper, opts ...RoundTripperOption) http.RoundTripper
- type Healthchecks
- type RoundTripper
- type RoundTripperOption
Constants ¶
const ( // MaxRetries for http requests MaxRetries = 5 // RetryDelay for http requests RetryDelay = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func EchoLogger ¶ added in v1.1.0
func EchoLogger() echo.Logger
EchoLogger is a wrapper around the zerolog logger (without sentry) that implements the echo.Logger interface.
func GetHub ¶ added in v1.1.0
GetHub returns the hub from the context (if context is provided and has a hub) or the current hub
func HealthcheckFail ¶ added in v1.2.0
HealthcheckFail sends a healthcheck fail event (if healthchecks are configured)
func Log ¶
Log returns a logger with the context provided, if no context is provided, it will return a logger with a new context
func NewContext ¶
NewContext creates a new context with a logger and sentry hub
func NewLogger ¶
func NewLogger(ctx context.Context, sentryOpts ...zlogsentry.WriterOption) *zerolog.Logger
NewLogger returns a new logger with sentry integration (if possible)
func NewLoggerPlain ¶ added in v1.1.2
NewLoggerPlain returns a new logger without sentry integration
func SetHealthchecks ¶ added in v1.2.0
func SetHealthchecks(h Healthchecks)
SetHealthchecks sets the healthchecks client
func StartSpan ¶
StartSpan starts a new span, and if there is no transaction, it starts a new transaction
func WithSentry ¶
func WithSentry() echo.MiddlewareFunc
WithSentry is a middleware that creates a new transaction for each request.
func WrapClient ¶
func WrapClient(c *http.Client, opts ...RoundTripperOption) *http.Client
WrapClient wraps an http.Client with APM instrumentation and retry logic
func WrapRoundTripper ¶
func WrapRoundTripper(rt http.RoundTripper, opts ...RoundTripperOption) http.RoundTripper
WrapRoundTripper wraps an http.RoundTripper with APM instrumentation and retry logic
Types ¶
type Healthchecks ¶ added in v1.2.0
Healthchecks is the interface for gitlab.com/etke.cc/go/healthchecks, to avoid direct dependecy on the package for project where it is not needed
type RoundTripper ¶ added in v1.1.0
type RoundTripper struct {
// contains filtered or unexported fields
}
RoundTripper is an http.RoundTripper that instruments http requests
type RoundTripperOption ¶ added in v1.1.0
type RoundTripperOption func(*RoundTripper)
RoundTripperOption is a function that configures an APMRoundTripper
func WithMaxRetries ¶
func WithMaxRetries(maxRetries int) RoundTripperOption
WithMaxRetries sets the maximum number of retries for http requests, otherwise defaults to 5
func WithRetryDelay ¶
func WithRetryDelay(retryDelay time.Duration) RoundTripperOption
WithRetryDelay sets the delay between retries for http requests, otherwise defaults to 5 seconds