sentry

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const FingerprintType = "sentry-fingerprint"
View Source
const TagType = "sentry-tag"

Variables

This section is empty.

Functions

func Fingerprint added in v1.3.3

func Fingerprint(key, value string) zap.Field

Fingerprint are used to group events into issues

func Hub added in v0.13.0

func Hub(hub *sentry.Hub) zapcore.Field

Hub attaches a Sentry hub to the logger such that if the logger ever logs an error, request context can be sent to Sentry.

func StreamServerInterceptor added in v0.18.2

func StreamServerInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

StreamServerInterceptor returns a new streaming server interceptor with the sentry hub placed in the context

func Tag added in v1.3.0

func Tag(key, value string) zap.Field

Tag attaches a tag which will be indexed by Sentry and searchable.

func UnaryServerInterceptor added in v0.18.2

func UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

UnaryServerInterceptor returns a new unary server interceptor with the sentry hub placed in the context

Types

type Config

type Config struct {
	DSN         string
	Environment string
	AppVersion  string
	Enabled     bool
}

Config defines the necessary configuration for instantiating a Sentry Reporter

func (Config) InitializeSentry added in v0.12.6

func (c Config) InitializeSentry() error

InitializeSentry Initializes the Sentry client. This function should be called as soon as possible after the application configuration is loaded so that sentry is set up.

func (*Config) RegisterFlags

func (c *Config) RegisterFlags(flags *pflag.FlagSet)

RegisterFlags registers Sentry flags with pflags

type Core

type Core struct {
	zapcore.LevelEnabler
	// contains filtered or unexported fields
}

Core Implements a zapcore.Core that sends logged errors to Sentry

func (*Core) Check

Check must be called before calling Write. This determines whether logs are sent to Sentry

func (*Core) Sync

func (c *Core) Sync() error

Sync flushes any buffered logs

func (*Core) With

func (c *Core) With(fields []zapcore.Field) zapcore.Core

With adds structured context to the Sentry Core

func (*Core) Write

func (c *Core) Write(ent zapcore.Entry, fields []zapcore.Field) error

Write logs the entry and fields supplied at the log site and writes them to their destination. If a Sentry Hub field is present in the fields, that Hub will be used for reporting to Sentry, otherwise the default Sentry Hub will be used.

type Middleware added in v0.13.0

type Middleware struct {
	// contains filtered or unexported fields
}

Middleware contains a Sentry handler

func NewMiddleware added in v0.13.0

func NewMiddleware() Middleware

NewMiddleware creates a new Sentry middleware object

func (Middleware) HTTP added in v0.13.0

func (m Middleware) HTTP(next http.Handler) http.Handler

HTTP is a wrapper around the sentry-go library's middleware that attaches a Sentry hub that from the request context to the logger. That way, if the logger ever writes an error log, instead of just sending the log message and fields provided to the logger to Sentry, Sentry is able to capture the entire request context i.e. the request path, headers present, etc. If this middleware is attached after the tracing middleware, the corresponding Trace ID will be added to the Sentry scope.

Jump to

Keyboard shortcuts

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