Documentation
¶
Index ¶
- Variables
- func AddBreadcrumb(category, message, level string, data map[string]interface{})
- func CaptureError(err error, component, operation string, tags ...map[string]string)
- func CaptureMessage(message, level, component, operation string, tags ...map[string]string)
- func Close()
- func Flush(timeout time.Duration) bool
- func Initialize(cfg *config.Config, version, commit, buildDate, author string) error
- func IsEnabled() bool
- type Client
- func (c *Client) AddBreadcrumb(category, message, level string, data map[string]interface{})
- func (c *Client) CaptureError(err error, component, operation string, tags map[string]string)
- func (c *Client) CaptureMessage(message, level, component, operation string, tags map[string]string)
- func (c *Client) Close()
- func (c *Client) Flush(timeout time.Duration) bool
- func (c *Client) GetSafeComponentContext(component, operation string) map[string]interface{}
- func (c *Client) GetSafeErrorMessage(err error) string
- func (c *Client) IsEnabled() bool
- func (c *Client) IsSensitiveError(err error) bool
- func (c *Client) WithContext(ctx context.Context) *Client
- type ComponentReporter
- func (cr *ComponentReporter) AddBreadcrumb(message, level string, data map[string]interface{})
- func (cr *ComponentReporter) CaptureError(err error, operation string, tags ...map[string]string)
- func (cr *ComponentReporter) CaptureMessage(message, level, operation string, tags ...map[string]string)
- func (cr *ComponentReporter) WithOperation(operation string) *OperationReporter
- type Config
- type LoggerFactory
- type Manager
- func (m *Manager) AddBreadcrumb(category, message, level string, data map[string]interface{})
- func (m *Manager) CaptureError(err error, component, operation string, tags ...map[string]string)
- func (m *Manager) CaptureMessage(message, level, component, operation string, tags ...map[string]string)
- func (m *Manager) Close()
- func (m *Manager) CreateComponentLogger(baseLogger zerolog.Logger, component, operation string) *SentryLoggerAdapter
- func (m *Manager) CreateLogger(baseLogger zerolog.Logger, component string) *SentryLoggerAdapter
- func (m *Manager) Flush(timeout time.Duration) bool
- func (m *Manager) IsEnabled() bool
- func (m *Manager) WithComponent(component string) *ComponentReporter
- type OperationReporter
- func (or *OperationReporter) AddBreadcrumb(message, level string, data map[string]interface{})
- func (or *OperationReporter) CaptureError(err error, tags ...map[string]string)
- func (or *OperationReporter) CaptureMessage(message, level string, tags ...map[string]string)
- func (or *OperationReporter) Failure(err error, data map[string]interface{})
- func (or *OperationReporter) Start()
- func (or *OperationReporter) Success(data map[string]interface{})
- type SentryLoggerAdapter
- func (s *SentryLoggerAdapter) AddBreadcrumb(category, message, level string, data map[string]interface{})
- func (s *SentryLoggerAdapter) CaptureError(err error, component, operation string)
- func (s *SentryLoggerAdapter) CaptureMessage(message, level, component, operation string)
- func (s *SentryLoggerAdapter) Close()
- func (s *SentryLoggerAdapter) Flush(timeout time.Duration) bool
- func (s *SentryLoggerAdapter) GetZerologLogger() zerolog.Logger
- func (s *SentryLoggerAdapter) WithComponent(component string) *SentryLoggerAdapter
- func (s *SentryLoggerAdapter) WithOperation(operation string) *SentryLoggerAdapter
- type ZerologHook
Constants ¶
This section is empty.
Variables ¶
var SensitiveFields = []string{
"command", "cmd", "exec", "run", "query", "sql",
"user", "username", "login", "email", "mail",
"password", "passwd", "pwd", "pass", "secret",
"token", "jwt", "bearer", "auth", "key",
"path", "file", "filename", "filepath", "dir", "directory",
"data", "payload", "body", "content", "message",
"session", "session_id", "session_key",
"encrypted", "encrypted_data", "cipher",
}
SensitiveFields contains field names that should be sanitized
var SensitivePatterns = struct { Command *regexp.Regexp FilePath *regexp.Regexp Username *regexp.Regexp Email *regexp.Regexp Token *regexp.Regexp Key *regexp.Regexp Password *regexp.Regexp HomeDir *regexp.Regexp SQLQuery *regexp.Regexp }{ Command: regexp.MustCompile(`(?i)(command|cmd|exec|run)[:=]\s*['""]?([^'""]+)['""]?`), FilePath: regexp.MustCompile(`(?i)(/home/[^/\s]+|/Users/[^/\s]+|C:\\Users\\[^\\]+|[A-Za-z]:\\Users\\[^\\]+)`), Username: regexp.MustCompile(`(?i)(user|username|login)[:=]\s*['""]?([^'""]+)['""]?`), Email: regexp.MustCompile(`[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}`), Token: regexp.MustCompile(`(?i)(token|jwt|bearer|auth)[:=]\s*['""]?([a-zA-Z0-9._-]+)['""]?`), Key: regexp.MustCompile(`(?i)(key|secret|password|pass)[:=]\s*['""]?([^'""]+)['""]?`), Password: regexp.MustCompile(`(?i)(password|passwd|pwd)[:=]\s*['""]?([^'""]+)['""]?`), HomeDir: regexp.MustCompile(`(?i)(home|user).*?[/\\]([^/\\]+)[/\\]`), SQLQuery: regexp.MustCompile(`(?i)(select|insert|update|delete|create|drop|alter).*?from.*?`), }
SensitivePatterns contains regex patterns for detecting sensitive information
Functions ¶
func AddBreadcrumb ¶
func CaptureError ¶
Convenience functions for global access
func CaptureMessage ¶
func Initialize ¶
Initialize initializes the global Sentry manager
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Sentry client with CommandChronicles-specific functionality
func (*Client) AddBreadcrumb ¶
AddBreadcrumb adds a safe breadcrumb for operation tracking
func (*Client) CaptureError ¶
CaptureError captures an error with safe context
func (*Client) CaptureMessage ¶
func (c *Client) CaptureMessage(message, level, component, operation string, tags map[string]string)
CaptureMessage captures a message with safe context
func (*Client) GetSafeComponentContext ¶
GetSafeComponentContext returns safe context information for a component
func (*Client) GetSafeErrorMessage ¶
GetSafeErrorMessage returns a safe version of an error message
func (*Client) IsSensitiveError ¶
IsSensitiveError checks if an error message contains sensitive information
type ComponentReporter ¶
type ComponentReporter struct {
// contains filtered or unexported fields
}
ComponentReporter provides component-specific error reporting
func WithComponent ¶
func WithComponent(component string) *ComponentReporter
func (*ComponentReporter) AddBreadcrumb ¶
func (cr *ComponentReporter) AddBreadcrumb(message, level string, data map[string]interface{})
AddBreadcrumb adds a breadcrumb for this component
func (*ComponentReporter) CaptureError ¶
func (cr *ComponentReporter) CaptureError(err error, operation string, tags ...map[string]string)
CaptureError captures an error for this component
func (*ComponentReporter) CaptureMessage ¶
func (cr *ComponentReporter) CaptureMessage(message, level, operation string, tags ...map[string]string)
CaptureMessage captures a message for this component
func (*ComponentReporter) WithOperation ¶
func (cr *ComponentReporter) WithOperation(operation string) *OperationReporter
WithOperation creates an operation-specific reporter
type Config ¶
type Config struct {
Enabled bool `toml:"enabled"`
DSN string `toml:"dsn"`
Environment string `toml:"environment"`
SampleRate float64 `toml:"sample_rate"`
Debug bool `toml:"debug"`
Release string `toml:"release"`
}
Config contains Sentry-specific configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns default Sentry configuration
type LoggerFactory ¶
type LoggerFactory struct {
// contains filtered or unexported fields
}
LoggerFactory creates loggers with Sentry integration
func NewLoggerFactory ¶
func NewLoggerFactory(client *Client) *LoggerFactory
NewLoggerFactory creates a new logger factory
func (*LoggerFactory) CreateComponentLogger ¶
func (f *LoggerFactory) CreateComponentLogger(baseLogger zerolog.Logger, component, operation string) *SentryLoggerAdapter
CreateComponentLogger creates a component-specific logger
func (*LoggerFactory) CreateLogger ¶
func (f *LoggerFactory) CreateLogger(baseLogger zerolog.Logger, component string) *SentryLoggerAdapter
CreateLogger creates a new logger with Sentry integration
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides global access to Sentry functionality
func (*Manager) AddBreadcrumb ¶
AddBreadcrumb adds a breadcrumb for operation tracking
func (*Manager) CaptureError ¶
CaptureError captures an error with safe context
func (*Manager) CaptureMessage ¶
func (m *Manager) CaptureMessage(message, level, component, operation string, tags ...map[string]string)
CaptureMessage captures a message with safe context
func (*Manager) CreateComponentLogger ¶
func (m *Manager) CreateComponentLogger(baseLogger zerolog.Logger, component, operation string) *SentryLoggerAdapter
CreateComponentLogger creates a component and operation specific logger
func (*Manager) CreateLogger ¶
func (m *Manager) CreateLogger(baseLogger zerolog.Logger, component string) *SentryLoggerAdapter
CreateLogger creates a new logger with Sentry integration
func (*Manager) WithComponent ¶
func (m *Manager) WithComponent(component string) *ComponentReporter
WithComponent creates a component-specific error reporter
type OperationReporter ¶
type OperationReporter struct {
// contains filtered or unexported fields
}
OperationReporter provides component and operation specific error reporting
func (*OperationReporter) AddBreadcrumb ¶
func (or *OperationReporter) AddBreadcrumb(message, level string, data map[string]interface{})
AddBreadcrumb adds a breadcrumb for this component and operation
func (*OperationReporter) CaptureError ¶
func (or *OperationReporter) CaptureError(err error, tags ...map[string]string)
CaptureError captures an error for this component and operation
func (*OperationReporter) CaptureMessage ¶
func (or *OperationReporter) CaptureMessage(message, level string, tags ...map[string]string)
CaptureMessage captures a message for this component and operation
func (*OperationReporter) Failure ¶
func (or *OperationReporter) Failure(err error, data map[string]interface{})
Failure marks the failure of an operation
func (*OperationReporter) Start ¶
func (or *OperationReporter) Start()
Start marks the beginning of an operation
func (*OperationReporter) Success ¶
func (or *OperationReporter) Success(data map[string]interface{})
Success marks the successful completion of an operation
type SentryLoggerAdapter ¶
type SentryLoggerAdapter struct {
// contains filtered or unexported fields
}
SentryLoggerAdapter wraps a zerolog.Logger with Sentry integration
func NewSentryLoggerAdapter ¶
func NewSentryLoggerAdapter(logger zerolog.Logger, client *Client) *SentryLoggerAdapter
NewSentryLoggerAdapter creates a new logger adapter with Sentry integration
func (*SentryLoggerAdapter) AddBreadcrumb ¶
func (s *SentryLoggerAdapter) AddBreadcrumb(category, message, level string, data map[string]interface{})
AddBreadcrumb adds a breadcrumb to Sentry
func (*SentryLoggerAdapter) CaptureError ¶
func (s *SentryLoggerAdapter) CaptureError(err error, component, operation string)
CaptureError directly captures an error with context
func (*SentryLoggerAdapter) CaptureMessage ¶
func (s *SentryLoggerAdapter) CaptureMessage(message, level, component, operation string)
CaptureMessage directly captures a message with context
func (*SentryLoggerAdapter) Close ¶
func (s *SentryLoggerAdapter) Close()
Close closes the Sentry client
func (*SentryLoggerAdapter) Flush ¶
func (s *SentryLoggerAdapter) Flush(timeout time.Duration) bool
Flush flushes pending Sentry events
func (*SentryLoggerAdapter) GetZerologLogger ¶
func (s *SentryLoggerAdapter) GetZerologLogger() zerolog.Logger
GetZerologLogger returns the underlying zerolog logger
func (*SentryLoggerAdapter) WithComponent ¶
func (s *SentryLoggerAdapter) WithComponent(component string) *SentryLoggerAdapter
WithComponent adds component context to the logger
func (*SentryLoggerAdapter) WithOperation ¶
func (s *SentryLoggerAdapter) WithOperation(operation string) *SentryLoggerAdapter
WithOperation adds operation context to the logger
type ZerologHook ¶
type ZerologHook struct {
// contains filtered or unexported fields
}
ZerologHook implements zerolog.Hook to integrate Sentry with zerolog
func NewZerologHook ¶
func NewZerologHook(client *Client, minLevel zerolog.Level) *ZerologHook
NewZerologHook creates a new zerolog hook for Sentry integration