Documentation
¶
Overview ¶
Package sentryx wraps github.com/getsentry/sentry-go with configuration from config so the rest of the service does not need to know about Sentry's surface area.
Role in architecture:
- Infrastructure: initializes the global Sentry hub and provides Flush for shutdown.
- Settings are loaded via config.GetConfig().Sentry (or config.Setup).
Responsibilities:
- Init: configure DSN, environment, release, server name, sample rates, and stack traces.
- LoadConfig: read SentryConfiguration from the global config package.
- Flush: drain buffered events with a timeout (safe when Sentry was never initialized).
- ServerOptions / DialOptions: gRPC interceptors (github.com/getsentry/sentry-go/grpc).
Constraints:
- SENTRY_DSN empty is the explicit "Sentry is off" signal — Init is a no-op and returns false.
- Init returns bool (enabled), not error; invalid DSN is logged and treated as off.
- The service must keep running whether Sentry is on, off, or misconfigured.
- Default server name is "app" when SENTRY_SERVER_NAME is empty.
- Sample rates outside [0, 1] are clamped to safe defaults (1.0 errors, 0.0 traces).
This package must NOT:
- Contain use-case or domain logic.
- Fail process startup when Sentry cannot be enabled.
Index ¶
- func DialOptions() []grpc.DialOption
- func Flush(timeout time.Duration)
- func Init(cfg config.SentryConfiguration) bool
- func LoadConfig() config.SentryConfiguration
- func ServerOptions(opts ...GRPCServerOptions) []grpc.ServerOption
- func StreamClientInterceptor() grpc.StreamClientInterceptor
- func StreamServerInterceptor(opts GRPCServerOptions) grpc.StreamServerInterceptor
- func UnaryClientInterceptor() grpc.UnaryClientInterceptor
- func UnaryServerInterceptor(opts GRPCServerOptions) grpc.UnaryServerInterceptor
- type GRPCServerOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DialOptions ¶ added in v0.5.6
func DialOptions() []grpc.DialOption
DialOptions returns unary + stream Sentry interceptors for grpc.NewClient / Dial.
func Flush ¶
Flush drains any buffered events. Safe to call when Sentry was never initialised (returns immediately). Use defer sentryx.Flush(cfg.FlushTimeout) right after Init so SIGTERM doesn't drop the panic that caused the shutdown.
func Init ¶
func Init(cfg config.SentryConfiguration) bool
Init configures the global Sentry hub. Returning a boolean (enabled) instead of an error keeps the caller simple — when DSN is empty we report "off" and proceed silently, when DSN is set but invalid Sentry's own Init returns an error which we log and treat as "off" (the service must keep running either way).
func LoadConfig ¶
func LoadConfig() config.SentryConfiguration
LoadConfig returns Sentry settings from the global config package.
func ServerOptions ¶ added in v0.5.6
func ServerOptions(opts ...GRPCServerOptions) []grpc.ServerOption
ServerOptions returns unary + stream Sentry interceptors for grpc.NewServer. Defaults Repanic to true so panics still abort the RPC after capture.
func StreamClientInterceptor ¶ added in v0.5.6
func StreamClientInterceptor() grpc.StreamClientInterceptor
StreamClientInterceptor returns a Sentry stream client interceptor.
func StreamServerInterceptor ¶ added in v0.5.6
func StreamServerInterceptor(opts GRPCServerOptions) grpc.StreamServerInterceptor
StreamServerInterceptor returns a Sentry stream server interceptor.
func UnaryClientInterceptor ¶ added in v0.5.6
func UnaryClientInterceptor() grpc.UnaryClientInterceptor
UnaryClientInterceptor returns a Sentry unary client interceptor.
func UnaryServerInterceptor ¶ added in v0.5.6
func UnaryServerInterceptor(opts GRPCServerOptions) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a Sentry unary server interceptor. Prefer ServerOptions() when wiring a new grpc.Server.
Types ¶
type GRPCServerOptions ¶ added in v0.5.6
type GRPCServerOptions struct {
// Repanic re-panics after recovery so other interceptors can still see the panic.
// Defaults to true when using ServerInterceptorOptions / default helpers.
Repanic bool
// WaitForDelivery blocks until the panic event is flushed to Sentry.
WaitForDelivery bool
// Timeout is the max wait for WaitForDelivery. Zero uses Sentry's default flush timeout.
Timeout time.Duration
}
GRPCServerOptions configures Sentry gRPC server interceptors.