sentry

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package sentry is a helper package for sentry integration

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidConfiguration = errors.New("invalid configuration")

ErrInvalidConfiguration is returned when the configuration is invalid

Functions

func NewLogger

func NewLogger() *zap.SugaredLogger

NewLogger creates a new zap logger with the appropriate configuration based on the viper settings for pretty and debug

Types

type Config

type Config struct {
	// Enabled indicates whether the Sentry client is enabled
	Enabled bool `json:"enabled" koanf:"enabled" default:"false"`
	// DSN is the Data Source Name for the Sentry client
	DSN string `json:"dsn" koanf:"dsn"`
	// Environment is the environment in which the Sentry client is running
	Environment string `json:"environment" koanf:"environment" default:"development"`
	// EnableTracing indicates whether tracing is enabled for the Sentry client
	EnableTracing bool `json:"enableTracing" koanf:"enableTracing" default:"false"`
	// TracesSampler is the sampling rate for tracing in the Sentry client
	TracesSampler float64 `json:"traceSampler" koanf:"traceSampler" default:"1.0"`
	// AttachStacktrace indicates whether to attach stack traces to events in the Sentry client
	AttachStacktrace bool `json:"attachStacktrace" koanf:"attachStacktrace" default:"true"`
	// SampleRate is the sampling rate for events in the Sentry client
	SampleRate float64 `json:"sampleRate" koanf:"sampleRate" default:"0.2"`
	// TracesSampleRate is the sampling rate for tracing events in the Sentry client
	TracesSampleRate float64 `json:"traceSampleRate" koanf:"traceSampleRate" default:"0.2"`
	// ProfilesSampleRate is the sampling rate for profiling events in the Sentry client
	ProfilesSampleRate float64 `json:"profileSampleRate" koanf:"profileSampleRate" default:"0.2"`
	// Repanic indicates whether to repanic after capturing an event in the Sentry client
	Repanic bool `json:"repanic" koanf:"repanic" ignored:"true"`
	// Debug indicates whether debug mode is enabled for the Sentry client
	Debug bool `json:"debug" koanf:"debug" default:"false"`
	// ServerName is the name of the server running the Sentry client
	ServerName string `json:"serverName" koanf:"serverName"`
}

Config settings for the Sentry client

func (Config) ClientOptions

func (c Config) ClientOptions() sentry.ClientOptions

ClientOptions returns the sentry.ClientOptions for the configuration

func (Config) UsePerformanceTracking

func (c Config) UsePerformanceTracking() bool

UsePerformanceTracking tracking is enabled if Sentry is enabled and track performance is explicitly set

func (Config) UseSentry

func (c Config) UseSentry() bool

UseSentry true if Sentry is enabled (e.g. a DSN is configured)

func (Config) Validate

func (c Config) Validate() error

Validate the configuration

type SentryZapCore

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

SentryZapCore is a zap core that sends logs to sentry

func (*SentryZapCore) Check

func (s *SentryZapCore) Check(entry zapcore.Entry, checkedEntry *zapcore.CheckedEntry) *zapcore.CheckedEntry

Check returns a checked entry if the log level is enabled for the core

func (*SentryZapCore) Enabled

func (s *SentryZapCore) Enabled(level zapcore.Level) bool

Enabled returns true if the log level is enabled

func (*SentryZapCore) Sync

func (s *SentryZapCore) Sync() error

Sync flushes the sentry event

func (*SentryZapCore) With

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

With returns a new core with the fields added

func (*SentryZapCore) Write

func (s *SentryZapCore) Write(entry zapcore.Entry, fields []zapcore.Field) error

Write sends the log entry to sentry

Jump to

Keyboard shortcuts

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