common

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSentry

func InitSentry(opts sentry.ClientOptions) error

InitSentry is a shared function for initializing the global "hub" object that manages scopes and clients for Sentry.

Unfortunately while Sentry supports several hubs, the default and most commonly used one is "CurrentHub", a package level variable that cannot be set up concurrently (it is data race free but not race condition free). Ideally each logger instance would have their own hub, but users will likely expect this to set up Sentry "in total". For now just do what we can so that multiple logger instances use the same thing if desired.

func ParseFrame

func ParseFrame(str string) sentry.Frame

ParseFrame parses a single sentry.Frame from a string produced by a StackTracer.

func ParseFrames

func ParseFrames(vals ...interface{}) []sentry.Frame

ParseFrames returns a slice of sentry.Frames for string values produced by a StackTracer. It accepts interfaces as it is meant to be used with JSON marshaling; otherwise call ParseFrame directly.

Types

type StackTracer

type StackTracer interface {
	StackTrace() errors.StackTrace
}

StackTracer defines a common interface for extracting stack information. Sentry and several other packages use this interface.

func WithStackTrace

func WithStackTrace(err error) (StackTracer, error)

WithStackTrace ensures that an error has a stack trace, and pairs it with a StackTracer.

It checks if the given error implements StackTracer and returns it if it does. Otherwise it will wrap the error in an error type that implements StackTracer and returns both.

If nil is passed then nil is returned.

Jump to

Keyboard shortcuts

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