sentry

package
v1.20210220.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: MIT Imports: 12 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"
)

Constants

View Source
const (
	// ListenerName is the sentry listener name.
	ListenerName = "sentry"
)

Variables

This section is empty.

Functions

func AddListeners

func AddListeners(log logger.Listenable, cfg Config)

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