obs

package
v0.0.0-...-766d99d Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package obs centralises crash reporting and selective error capture via Sentry. Init is a one-shot called from the daemon entry point; after that, callers use Go/SafeGo to launch goroutines with panic recovery and Capture/CaptureMsg to forward selected errors.

When Sentry is disabled or the DSN is empty, every function becomes a no-op wrapper with the same semantics as a plain `go func()` call, so guarded call sites work unchanged in tests and in operator builds that opt out of telemetry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capture

func Capture(component string, err error)

Capture sends an error to Sentry with a component tag. No-op when disabled or err is nil. Reserve for unexpected states and invariant violations; expected-failure errors (permission denied, transient network) should stay out of Sentry to avoid noise.

func CaptureMsg

func CaptureMsg(component, msg string)

CaptureMsg is Capture for string-only events (e.g. invariant violations without a wrapped error).

func Enabled

func Enabled() bool

Enabled reports whether Init succeeded and Sentry is live.

func Flush

func Flush()

Flush waits for queued events to be sent before returning. Call from shutdown paths before exit. Safe to call when Sentry is disabled.

func Go

func Go(component string, fn func())

Go launches fn in a new goroutine. A panic in fn is captured with the given component tag, the event is flushed, and the panic is re-raised so the existing crash-and-systemd-restart behavior is preserved. Use this for long-lived supervisor goroutines where a silent death would leave the daemon in a degraded state.

func Init

func Init(cfg *config.Config, version, buildHash string) error

Init configures the Sentry SDK once at daemon startup. Returns nil if Sentry is disabled or the DSN is empty so callers can treat init as optional. Safe to call when cfg is nil.

func SafeGo

func SafeGo(component string, fn func())

SafeGo is Go but swallows the panic after capture. Use this for per-request handlers (socket accept, HTTP request) where one bad input should not crash the whole daemon.

Types

This section is empty.

Jump to

Keyboard shortcuts

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