Documentation
¶
Overview ¶
Package observability provides error tracking, breadcrumbs, and monitoring for BubblyUI.
The observability package enables comprehensive error tracking and debugging capabilities for BubblyUI applications. It provides a pluggable error reporting system, breadcrumb trails for debugging, and integration with popular error tracking services like Sentry.
This package is an alias for github.com/newbpydev/bubblyui/pkg/bubbly/observability, providing a cleaner import path for users.
Error Reporting ¶
- ConsoleReporter: Logs errors to stdout (development)
- SentryReporter: Sends errors to Sentry (production)
- Custom implementations: Implement ErrorReporter for other services
Breadcrumbs ¶
Breadcrumbs provide a trail of events leading up to an error:
observability.RecordBreadcrumb("navigation", "User navigated to /users", map[string]interface{}{
"path": "/users",
})
Example ¶
import "github.com/newbpydev/bubblyui/observability"
// Development: Use console reporter
reporter := observability.NewConsoleReporter(true)
observability.SetErrorReporter(reporter)
// Production: Use Sentry
reporter, err := observability.NewSentryReporter(os.Getenv("SENTRY_DSN"),
observability.WithEnvironment("production"),
observability.WithRelease("v1.0.0"),
)
if err != nil {
log.Fatal(err)
}
observability.SetErrorReporter(reporter)
defer reporter.Flush(5 * time.Second)
Index ¶
Constants ¶
const MaxBreadcrumbs = observability.MaxBreadcrumbs
MaxBreadcrumbs is the maximum number of breadcrumbs stored.
Variables ¶
var ClearBreadcrumbs = observability.ClearBreadcrumbs
ClearBreadcrumbs removes all recorded breadcrumbs.
var GetBreadcrumbs = observability.GetBreadcrumbs
GetBreadcrumbs returns all recorded breadcrumbs.
var GetErrorReporter = observability.GetErrorReporter
GetErrorReporter returns the current global error reporter.
var NewConsoleReporter = observability.NewConsoleReporter
NewConsoleReporter creates a new console reporter. Set verbose to true for detailed output.
var RecordBreadcrumb = observability.RecordBreadcrumb
RecordBreadcrumb adds a breadcrumb to the trail.
var SetErrorReporter = observability.SetErrorReporter
SetErrorReporter sets the global error reporter.
var WithDebug = observability.WithDebug
WithDebug enables Sentry debug mode.
var WithEnvironment = observability.WithEnvironment
WithEnvironment sets the Sentry environment tag.
var WithRelease = observability.WithRelease
WithRelease sets the Sentry release version.
Functions ¶
This section is empty.
Types ¶
type Breadcrumb ¶
type Breadcrumb = observability.Breadcrumb
Breadcrumb represents a single breadcrumb trail entry.
type CommandGenerationError ¶
type CommandGenerationError = observability.CommandGenerationError
CommandGenerationError wraps panics during automatic command generation.
type ConsoleReporter ¶
type ConsoleReporter = observability.ConsoleReporter
ConsoleReporter logs errors to stdout for development.
type ErrorContext ¶
type ErrorContext = observability.ErrorContext
ErrorContext provides contextual information for error reports.
type ErrorReporter ¶
type ErrorReporter = observability.ErrorReporter
ErrorReporter defines the interface for error reporting implementations.
type HandlerPanicError ¶
type HandlerPanicError = observability.HandlerPanicError
HandlerPanicError wraps panics that occur in event handlers.
type SentryOption ¶
type SentryOption = observability.SentryOption
SentryOption configures the Sentry reporter.
func WithBeforeSend ¶
WithBeforeSend sets a callback to modify events before sending.
type SentryReporter ¶
type SentryReporter = observability.SentryReporter
SentryReporter sends errors to Sentry for production monitoring.
func NewSentryReporter ¶
func NewSentryReporter(dsn string, opts ...SentryOption) (*SentryReporter, error)
NewSentryReporter creates a new Sentry reporter with the given DSN.