Help us shape the future of Go! Take the 2026 Go Developer Survey

observability

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package observability wires optional Sentry-wire error reporting (e.g. the self-hosted GlitchTip at errors.example.com) into filex. Everything here is a no-op unless a DSN is configured, so a default build reports nothing.

The primary integration is a slog.Handler that forwards WARN+ERROR log records to Sentry, so operational failures already surfaced via slog — the worker's "ops: step failed", storage errors, recovered panics — show up in GlitchTip without sprinkling capture calls through the codebase.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Flush

func Flush()

Flush drains buffered events — call on shutdown. No-op when uninitialized.

func Init

func Init(dsn, environment, release string) bool

Init initializes the global Sentry client. Returns false (reporting stays off) when dsn is empty or init fails, so callers can skip the slog wrapper.

func WrapSlog

func WrapSlog(inner slog.Handler) slog.Handler

WrapSlog wraps inner so WARN/ERROR records are teed to Sentry.

Types

type SlogHandler

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

SlogHandler wraps a base slog.Handler and forwards WARN+ERROR records to Sentry (grouped by log message), so operational failures land in GlitchTip. WARN is only forwarded when it carries an `err` attribute — that filters out benign warnings while keeping real failures like "ops: step failed".

Every attribute on the record travels with the event, because an event without them is not actionable: "thumb generate failed" is a question ("which file? which error?") until `path` and `err` are next to it. Short values become tags — searchable, shown in the issue list — and the full set (long values included) goes into the `log` context. Values whose key looks like a credential are replaced with a marker before either.

func (*SlogHandler) Enabled

func (h *SlogHandler) Enabled(ctx context.Context, l slog.Level) bool

func (*SlogHandler) Handle

func (h *SlogHandler) Handle(ctx context.Context, r slog.Record) error

func (*SlogHandler) WithAttrs

func (h *SlogHandler) WithAttrs(as []slog.Attr) slog.Handler

func (*SlogHandler) WithGroup

func (h *SlogHandler) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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