Documentation
¶
Overview ¶
Package sentry provides an enhanced wrapper around the Sentry Go SDK with additional functionality for error exclusion, automatic tag enrichment, and context data extraction.
The main Client interface wraps the official Sentry Go SDK and adds:
- Automatic tag extraction from context and errors
- Configurable error filtering to reduce noise
- Enhanced integration with github.com/bborbe/errors for context data
- Proxy support for HTTP transport
Example usage:
client, err := sentry.NewClient(ctx, sentry.ClientOptions{
Dsn: "your-dsn-here",
Tags: map[string]string{"service": "my-app"},
})
if err != nil {
return err
}
defer client.Close()
// Capture exception with automatic tag enrichment
client.CaptureException(err, &sentry.EventHint{Context: ctx}, nil)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewProxyRoundTripper ¶
func NewProxyRoundTripper( roundtripper http.RoundTripper, url string, ) http.RoundTripper
NewProxyRoundTripper creates an HTTP RoundTripper that proxies Sentry requests to a different host without modifying the alert content. This is useful for routing Sentry traffic through a proxy server or testing with a local Sentry instance.
func NewSkipErrorAndReport ¶
NewSkipErrorAndReport creates a run.Func that executes the given action and reports any errors to Sentry without propagating the error. The returned function always returns nil, making it suitable for fire-and-forget operations where errors should be logged and reported but not halt execution.
Types ¶
type Client ¶
type Client interface {
CaptureMessage(
message string,
hint *sentry.EventHint,
scope sentry.EventModifier,
) *sentry.EventID
CaptureException(
exception error,
hint *sentry.EventHint,
scope sentry.EventModifier,
) *sentry.EventID
Flush(timeout stdtime.Duration) bool
io.Closer
}
Client provides an enhanced interface for interacting with Sentry error tracking. It wraps the official Sentry Go SDK and adds automatic tag enrichment from context and errors, configurable error filtering, and enhanced integration with github.com/bborbe/errors.
func NewClient ¶
func NewClient( ctx context.Context, clientOptions sentry.ClientOptions, excludeErrors ...ExcludeError, ) (Client, error)
NewClient creates a new Sentry client with enhanced functionality including automatic tag enrichment and error filtering. It accepts standard Sentry ClientOptions and optional ExcludeError functions to filter out specific errors from being sent to Sentry.
WARNING: Do not pass sensitive information (passwords, API keys, PII, tokens) in hint.Data, context data, or error data as these will be sent to Sentry as tags and may be stored or logged externally.
type EventModifier ¶ added in v1.8.3
type EventModifier interface {
sentry.EventModifier
}
EventModifier provides an interface for modifying Sentry events before they are sent. It wraps the sentry.EventModifier interface to allow custom event processing.
type EventModifierFunc ¶ added in v1.8.3
type EventModifierFunc func(event *sentry.Event, hint *sentry.EventHint, client *sentry.Client) *sentry.Event
EventModifierFunc is a function type that implements the EventModifier interface. It allows using functions as event modifiers without creating a separate struct.
type EventModifierList ¶ added in v1.8.3
type EventModifierList []EventModifier
EventModifierList is a slice of EventModifiers that applies all modifiers in sequence. Each modifier receives the event modified by the previous modifier in the list.
func (EventModifierList) ApplyToEvent ¶ added in v1.8.3
func (e EventModifierList) ApplyToEvent( event *sentry.Event, hint *sentry.EventHint, client *sentry.Client, ) *sentry.Event
ApplyToEvent implements the EventModifier interface by applying all modifiers in the list sequentially. The event is passed through each modifier in order, with each modifier receiving the result of the previous one.
type ExcludeError ¶
ExcludeError is a function type that determines whether an error should be excluded from Sentry reporting. It returns true if the error should be excluded.
type ExcludeErrors ¶
type ExcludeErrors []ExcludeError
ExcludeErrors is a collection of ExcludeError functions that can be used to filter out specific errors from being sent to Sentry.
func (ExcludeErrors) IsExcluded ¶
func (e ExcludeErrors) IsExcluded(err error) bool
IsExcluded checks if the given error matches any of the exclude conditions. It returns true if any ExcludeError function in the collection returns true for the error.