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 GetStackTrace() string
- func HealthcheckFail(optionalBody ...io.Reader)
- func Log(ctx ...context.Context) *zerolog.Logger
- func NewContext(parent ...context.Context) context.Context
- func NewLogger(ctx context.Context) *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 ¶
EchoLogger is a wrapper around the zerolog logger (without sentry) that implements the echo.Logger interface.
func GetHub ¶
GetHub returns the hub from the context (if context is provided and has a hub) or the current hub
func GetStackTrace ¶ added in v1.3.3
func GetStackTrace() string
GetStackTrace returns the stack trace, skipping the apm and logger packages
func HealthcheckFail ¶
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 NewLoggerPlain ¶
NewLoggerPlain returns a new logger without sentry integration
func SetHealthchecks ¶
func SetHealthchecks(h Healthchecks)
SetHealthchecks sets the healthchecks client
func SetSentryDSN ¶
func SetSentryDSN(dsn string)
SetSentryDSN sets the sentry DSN and initializes it
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 ¶
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 ¶
type RoundTripper struct {
// contains filtered or unexported fields
}
RoundTripper is an http.RoundTripper that instruments http requests
type RoundTripperOption ¶
type RoundTripperOption func(*RoundTripper)
RoundTripperOption is a function that configures an APMRoundTripper
func WithHealthchecks ¶ added in v1.3.5
func WithHealthchecks(enabled bool) RoundTripperOption
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