Documentation
¶
Overview ¶
Package observability wires kombify Go services into Sentry for error reporting and performance tracing.
This is the SINGLE SOURCE OF TRUTH for how internal kombify Go services initialize Sentry — defaults (sample rates, PII scrubbing, release tagging, user-context extraction from edgeauth headers) are enforced here so every service gets identical, DSGVO-safe behavior.
Scope: SaaS services only (Ebene 2 per PRODUCT-SEGMENTATION.md). OSS tools (Ebene 1 — Sim, SpeechKit, StackKits, TechStack-OSS) MUST NOT import this package. See ../kombify Core/standards/OBSERVABILITY-STANDARD.md.
Usage:
func main() {
shutdown := observability.MustInit(observability.Config{
Service: "kombify-cloud-backend",
Environment: os.Getenv("SENTRY_ENVIRONMENT"),
Release: os.Getenv("SENTRY_RELEASE"),
})
defer shutdown()
mux := http.NewServeMux()
// ... register handlers ...
http.ListenAndServe(":8080", observability.Middleware(mux))
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrObservabilityDisabled = errors.New("observability: disabled (no SENTRY_DSN)")
ErrObservabilityDisabled is returned by utilities that require Sentry but the SDK is in no-op mode. Rarely needed — most code should check with IsEnabled() before branching.
Functions ¶
func CaptureErr ¶
CaptureErr reports err to Sentry attached to the request hub when present, otherwise to the global hub. Returns the original error unchanged so it can be used in `return observability.CaptureErr(ctx, err)` chains.
func IsEnabled ¶
func IsEnabled() bool
IsEnabled reports whether Sentry was initialized successfully.
func Middleware ¶
Middleware wraps an http.Handler with:
- Panic recovery (reported to Sentry, then re-raised as 500)
- Request-scoped Sentry hub
- User context from edgeauth identity headers (via identity.FromContext)
Use AFTER edgeauth.Middleware so identity is already in context.
Types ¶
type Config ¶
type Config struct {
// Service is the Sentry project slug (e.g. "kombify-cloud-backend").
// Required when Enabled=true.
Service string
// DSN is the Sentry DSN. Defaults to os.Getenv("SENTRY_DSN").
// When empty, observability is disabled (safe for local dev).
DSN string
// Environment is the Sentry environment tag ("prod", "dev", "preview").
// Defaults to os.Getenv("SENTRY_ENVIRONMENT") or "prod".
Environment string
// Release is the release identifier, typically the Git SHA.
// Defaults to os.Getenv("SENTRY_RELEASE").
Release string
// TracesSampleRate overrides the default (0.1 in prod, 1.0 in dev).
TracesSampleRate *float64
// Debug enables Sentry SDK debug logging.
Debug bool
}
Config configures Sentry initialization for a kombify SaaS Go service.