Documentation
¶
Overview ¶
Package sentry provides a Sentry integration hook for the enterprise logging framework.
This is the stub file used when the "sentry" build tag is NOT enabled. All functions are no-ops so that code importing this package compiles without the github.com/getsentry/sentry-go dependency.
Enabling the real implementation ¶
To enable the real Sentry hook, build with the "sentry" tag and add the dependency:
go get github.com/getsentry/sentry-go go build -tags sentry
When the tag is active, hook.go (instead of this file) is compiled and the hook captures error-level log records and sends them to Sentry.
Index ¶
- type HookConfig
- type SentryHook
- func (h *SentryHook) AfterWrite(ctx context.Context, record slog.Record, payload []byte, writeErr error)
- func (h *SentryHook) BeforeWrite(ctx context.Context, record slog.Record) (slog.Record, error)
- func (h *SentryHook) Flush()
- func (h *SentryHook) FlushWithDuration(d time.Duration)
- func (h *SentryHook) Name() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HookConfig ¶
type HookConfig struct {
DSN string
Service string
Environment string
Release string
MinLevel core.Level
SampleRate float64
EnableBreadcrumbs bool
MaxBreadcrumbs int
FlushTimeout time.Duration
}
HookConfig configures the SentryHook. See hook.go (build tag "sentry") for full documentation.
var HookConfigGlobal HookConfig
HookConfigGlobal holds the Sentry configuration set by the application. See hook.go (build tag "sentry") for the implementation.
type SentryHook ¶
type SentryHook struct {
// contains filtered or unexported fields
}
SentryHook is a no-op stub that implements core.Hook. When the "sentry" build tag is enabled, this type captures error-level log records and sends them to Sentry.
To enable the real implementation:
go get github.com/getsentry/sentry-go go build -tags sentry
func NewHook ¶
func NewHook(cfg HookConfig) (*SentryHook, error)
NewHook creates a no-op SentryHook stub.
If DSN is empty, the stub is returned without error (graceful degradation). If DSN is non-empty, a warning is printed to stderr reminding the user to build with the "sentry" tag.
To enable the real implementation:
go get github.com/getsentry/sentry-go go build -tags sentry
func NewHookFromEnv ¶
func NewHookFromEnv() (*SentryHook, error)
NewHookFromEnv creates a no-op SentryHook stub from HookConfigGlobal or environment variables.
To enable the real implementation:
go get github.com/getsentry/sentry-go go build -tags sentry
func (*SentryHook) AfterWrite ¶
func (h *SentryHook) AfterWrite(ctx context.Context, record slog.Record, payload []byte, writeErr error)
AfterWrite is a no-op stub.
func (*SentryHook) BeforeWrite ¶
BeforeWrite is a no-op stub.
func (*SentryHook) FlushWithDuration ¶
func (h *SentryHook) FlushWithDuration(d time.Duration)
FlushWithDuration is a no-op stub.