notifier

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 16 Imported by: 2

README

GoDoc

notifier

import "github.com/go-coldbrew/errors/notifier"

Index

func Close

func Close()

Close closes the airbrake notifier and flushes the error queue. 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

func GetTraceId(ctx context.Context) string

GetTraceId fetches traceID from context if no trace id is found then it will return empty string

func InitAirbrake

func InitAirbrake(projectID int64, projectKey string)

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 InitSentry

func InitSentry(dsn string)

InitSentry inits sentry configuration dsn: sentry dsn

func Notify

func Notify(err error, rawData ...interface{}) error

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 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

func NotifyWithExclude(err error, rawData ...interface{}) error

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

func NotifyWithLevel(err error, level string, rawData ...interface{}) error

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

func NotifyWithLevelAndSkip(err error, skip int, level string, rawData ...interface{}) error

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 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 SetTraceId

func SetTraceId(ctx context.Context) context.Context

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 UpdateTraceId

func UpdateTraceId(ctx context.Context, traceID string) context.Context

UpdateTraceId force updates the traced id to provided id 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

type Tags

type Tags map[string]string

Generated by gomarkdoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close closes the airbrake notifier and flushes the error queue. 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

func GetTraceId(ctx context.Context) string

GetTraceId fetches traceID from context if no trace id is found then it will return empty string

func InitAirbrake

func InitAirbrake(projectID int64, projectKey string)

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 InitSentry

func InitSentry(dsn string)

InitSentry inits sentry configuration dsn: sentry dsn

func Notify

func Notify(err error, rawData ...interface{}) error

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 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

func NotifyWithExclude(err error, rawData ...interface{}) error

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

func NotifyWithLevel(err error, level string, rawData ...interface{}) error

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

func NotifyWithLevelAndSkip(err error, skip int, level string, rawData ...interface{}) error

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 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 SetTraceId

func SetTraceId(ctx context.Context) context.Context

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 UpdateTraceId

func UpdateTraceId(ctx context.Context, traceID string) context.Context

UpdateTraceId force updates the traced id to provided id 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

Types

type Tags

type Tags map[string]string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL