Documentation
¶
Index ¶
- func Close()
- func GetTraceHeaderName() string
- func GetTraceId(ctx context.Context) string
- func InitAirbrake(projectID int64, projectKey string)
- func InitRollbar(token, env string)
- func InitSentry(dsn string)
- func Notify(err error, rawData ...interface{}) error
- func NotifyAsync(err error, rawData ...interface{}) error
- func NotifyOnPanic(rawData ...interface{})
- func NotifyWithExclude(err error, rawData ...interface{}) error
- func NotifyWithLevel(err error, level string, rawData ...interface{}) error
- func NotifyWithLevelAndSkip(err error, skip int, level string, rawData ...interface{}) error
- func SetEnvironment(env string)
- func SetHostname(name string)
- func SetMaxAsyncNotifications(n int)
- func SetRelease(rel string)
- func SetServerRoot(path string)
- func SetTraceHeaderName(name string)
- func SetTraceIDValidator(fn func(string) string)
- func SetTraceId(ctx context.Context) context.Context
- func SetTraceIdWithValue(ctx context.Context) (context.Context, string)
- func UpdateTraceId(ctx context.Context, traceID string) context.Context
- type Tags
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close()
Close closes the airbrake notifier and flushes pending Sentry events. Sentry events are flushed with a 2 second timeout. You should call Close before app shutdown. Close doesn't call os.Exit.
func GetTraceHeaderName ¶
func GetTraceHeaderName() string
GetTraceHeaderName gets the header name for trace id default is x-trace-id
func GetTraceId ¶
GetTraceId fetches traceID from context if no trace id is found then it will return empty string
func InitAirbrake ¶
InitAirbrake inits airbrake configuration projectID: airbrake project id projectKey: airbrake project key
func InitRollbar ¶
func InitRollbar(token, env string)
InitRollbar inits rollbar configuration token: rollbar token env: rollbar environment
func Notify ¶
Notify notifies error to airbrake, rollbar and sentry if they are inited and error is not ignored err: error to notify rawData: extra data to notify with error (can be context.Context, Tags, or any other data) when rawData is context.Context, it will used to get extra data from loggers.FromContext(ctx) and tags from metadata
func NotifyAsync ¶ added in v0.2.2
NotifyAsync sends an error notification asynchronously with bounded concurrency. If the async notification pool is full, the notification is dropped to prevent goroutine explosion under sustained error bursts. Returns the original error for convenience.
func NotifyOnPanic ¶
func NotifyOnPanic(rawData ...interface{})
NotifyOnPanic notifies error to airbrake, rollbar and sentry if they are inited and error is not ignored rawData: extra data to notify with error (can be context.Context, Tags, or any other data) when rawData is context.Context, it will used to get extra data from loggers.FromContext(ctx) and tags from metadata this function should be called in defer example: defer NotifyOnPanic(ctx, "some data") example: defer NotifyOnPanic(ctx, "some data", Tags{"tag1": "value1"})
func NotifyWithExclude ¶
NotifyWithExclude notifies error to airbrake, rollbar and sentry if they are inited and error is not ignored err: error to notify rawData: extra data to notify with error (can be context.Context, Tags, or any other data) when rawData is context.Context, it will used to get extra data from loggers.FromContext(ctx) and tags from metadata
func NotifyWithLevel ¶
NotifyWithLevel notifies error to airbrake, rollbar and sentry if they are inited and error is not ignored err: error to notify level: error level rawData: extra data to notify with error (can be context.Context, Tags, or any other data) when rawData is context.Context, it will used to get extra data from loggers.FromContext(ctx) and tags from metadata
func NotifyWithLevelAndSkip ¶
NotifyWithLevelAndSkip notifies error to airbrake, rollbar and sentry if they are inited and error is not ignored err: error to notify skip: skip stack frames when notify error level: error level rawData: extra data to notify with error (can be context.Context, Tags, or any other data) when rawData is context.Context, it will used to get extra data from loggers.FromContext(ctx) and tags from metadata
func SetEnvironment ¶
func SetEnvironment(env string)
SetEnvironment sets the environment. The environment is used to distinguish errors occurring in different
func SetHostname ¶
func SetHostname(name string)
SetHostname sets the hostname of the server. The hostname is used to identify the server that logged an error.
func SetMaxAsyncNotifications ¶ added in v0.2.2
func SetMaxAsyncNotifications(n int)
SetMaxAsyncNotifications sets the maximum number of concurrent async notification goroutines. When the limit is reached, new async notifications are dropped to prevent goroutine explosion under sustained error bursts. Default is 20. The first successful call wins; subsequent calls are no-ops. It is safe to call concurrently with NotifyAsync.
func SetRelease ¶
func SetRelease(rel string)
SetRelease sets the release tag. The release tag is used to group errors together by release.
func SetServerRoot ¶
func SetServerRoot(path string)
SetServerRoot sets the root directory of the project. The root directory is used to trim prefixes from filenames in stack traces.
func SetTraceHeaderName ¶
func SetTraceHeaderName(name string)
SetTraceHeaderName sets the header name for trace id default is x-trace-id
func SetTraceIDValidator ¶ added in v0.2.11
SetTraceIDValidator sets a custom trace ID validation function. The function receives a raw trace ID and must return the sanitized version. Returning an empty string triggers the standard trace ID resolution flow (existing ctx → gRPC metadata → OTEL span trace ID → generate UUID), not direct generation. Set to nil to disable validation entirely (not recommended). Must be called during init — not safe for concurrent use.
func SetTraceId ¶
SetTraceId updates the traceID based on context values if no trace id is found then it will create one and update the context You should use the context returned by this function instead of the one passed
func SetTraceIdWithValue ¶ added in v0.2.10
SetTraceIdWithValue is like SetTraceId but also returns the resolved trace ID, avoiding a separate GetTraceId call. Callers must use the returned context, not the original ctx, so the stored trace ID is preserved in options and log context.