sentry

package
v1.20210402.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 13 Imported by: 2

Documentation

Overview

Package sentry provides helpers for logging errors to sentry from sdk primitives like the logger.

Index

Constants

View Source
const (
	Platform     = "go"
	SDK          = "sentry.go"
	ListenerName = "sentry"
)

Constants

Variables

View Source
var (
	// DefaultListenerFlags are the default log flags to notify Sentry for
	DefaultListenerFlags = []string{logger.Error, logger.Fatal}
)

Functions

func AddListeners

func AddListeners(log logger.Listenable, meta configmeta.Meta, cfg Config, opts ...AddListenersOption) error

AddListeners adds error listeners.

func GetFingerprint

func GetFingerprint(ctx context.Context) []string

GetFingerprint gets a context specific fingerprint from the context. You can set this with `WithFingerprint(...)`. It will override the default behavior of setting the fingerprint to the logger path + err.Error().

func WithFingerprint

func WithFingerprint(ctx context.Context, fingerprint ...string) context.Context

WithFingerprint sets the context fingerprint. You can use this to override the default fingerprint value submitted by the SDK to sentry.

Types

type AddListenersOption added in v1.20210402.2

type AddListenersOption func(options *AddListenersOptions)

AddListenersOption mutates AddListeners options

func AddListenersOptionFlags added in v1.20210402.2

func AddListenersOptionFlags(flags ...string) AddListenersOption

AddListenersOptionFlags sets the logger flags to send Sentry notifications for

func AddListenersOptionScopes added in v1.20210402.2

func AddListenersOptionScopes(scopes ...string) AddListenersOption

AddListenersOptionScopes sets the logger scopes to send Sentry notifications for

type AddListenersOptions added in v1.20210402.2

type AddListenersOptions struct {
	EnabledFlags []string
	Scopes       *logger.Scopes
}

AddListenersOptions are all the options we can set when adding Sentry error listeners

type Client

type Client struct {
	Config Config
	Client *raven.Client
}

Client is a wrapper for the sentry-go client.

func MustNew

func MustNew(cfg Config) *Client

MustNew returns a new client and panics on error.

func New

func New(cfg Config) (*Client, error)

New returns a new client.

func (Client) Notify

func (c Client) Notify(ctx context.Context, ee logger.ErrorEvent)

Notify sends a notification.

type Config

type Config struct {
	// The DSN to use. If the DSN is not set, the client is effectively disabled.
	DSN string `json:"dsn" yaml:"dsn"`
	// The server name to be reported.
	ServerName string `json:"serverName" yaml:"serverName"`
	// The dist to be sent with events.
	Dist string `json:"dist" yaml:"dist"`
	// The release to be sent with events.
	Release string `json:"release" yaml:"release"`
	// The environment to be sent with events.
	Environment string `json:"environment" yaml:"environment"`
	// Maximum number of breadcrumbs.
	MaxBreadcrumbs int `json:"maxBreadCrumbs" yaml:"maxBreadCrumbs"`
}

Config is the sentry config.

func (*Config) GetDSNHost added in v1.20210103.1

func (c *Config) GetDSNHost() string

GetDSNHost returns just the scheme and hostname for the dsn.

func (Config) IsZero

func (c Config) IsZero() bool

IsZero returns if the config is unset.

func (*Config) Resolve

func (c *Config) Resolve(ctx context.Context) error

Resolve applies configutil resoltion steps.

type Sender

type Sender interface {
	Notify(context.Context, logger.ErrorEvent)
}

Sender is the type that the sentry client ascribes to.

Jump to

Keyboard shortcuts

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