Documentation
¶
Index ¶
- func HTTPErrorHandlerWrapper(recorder ErrorRecorder, handler echo.HTTPErrorHandler) echo.HTTPErrorHandler
- func NewLogMonitor(config LogMonitorConfig) (*debugmonitor.Monitor, *slog.Logger)
- func NewQueryMonitor(config QueryMonitorConfig) (*debugmonitor.Monitor, *sql.DB)
- func NewRequestMonitor(config *RequestMonitorConfig) (*debugmonitor.Monitor, echo.MiddlewareFunc)
- func NewWriterMonitor(config WriterMonitorConfig) (*debugmonitor.Monitor, io.Writer)
- type ErrorMonitorConfig
- type ErrorPayload
- type ErrorRecorder
- type LogMonitorConfig
- type LogPayload
- type LogSkipper
- type QueryMonitorConfig
- type QueryPayload
- type RequestMonitorConfig
- type RequestPayload
- type TeeWriter
- type WriterMonitorConfig
- type WriterPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPErrorHandlerWrapper ¶
func HTTPErrorHandlerWrapper(recorder ErrorRecorder, handler echo.HTTPErrorHandler) echo.HTTPErrorHandler
HTTPErrorHandlerWrapper returns an echo.HTTPErrorHandler that records errors and then delegates to the provided handler.
func NewLogMonitor ¶ added in v5.1.0
func NewLogMonitor(config LogMonitorConfig) (*debugmonitor.Monitor, *slog.Logger)
NewLogMonitor creates a new monitor for logging and returns the monitor along with a wrapped slog.Logger.
func NewQueryMonitor ¶ added in v5.1.0
func NewQueryMonitor(config QueryMonitorConfig) (*debugmonitor.Monitor, *sql.DB)
NewQueryMonitor creates a new monitor for database queries and returns a wrapped *sql.DB. This function wraps an existing database driver with monitoring capabilities without requiring changes to existing *sql.DB usage code.
func NewRequestMonitor ¶ added in v5.1.0
func NewRequestMonitor(config *RequestMonitorConfig) (*debugmonitor.Monitor, echo.MiddlewareFunc)
NewRequestMonitor creates a new monitor for HTTP requests and returns the monitor along with an Echo middleware function that captures request information
func NewWriterMonitor ¶
func NewWriterMonitor(config WriterMonitorConfig) (*debugmonitor.Monitor, io.Writer)
NewWriterMonitor creates a new writer monitor with the given configuration. It returns the monitor and a new io.Writer that writes to both the original writer and the monitor's store.
Types ¶
type ErrorMonitorConfig ¶ added in v5.1.0
type ErrorMonitorConfig struct {
// UsePolling enables polling mode instead of SSE for real-time updates.
UsePolling bool
}
ErrorMonitorConfig defines the config for Error monitor.
type ErrorPayload ¶
type ErrorPayload struct {
Error string `json:"error"`
Type string `json:"type"`
Message string `json:"message"`
StackTrace string `json:"stackTrace"`
Timestamp time.Time `json:"timestamp"`
}
ErrorPayload represents the data structure for error monitoring
type ErrorRecorder ¶
type ErrorRecorder func(err error)
ErrorRecorder is a function type for recording errors
func NewErrorMonitor ¶ added in v5.1.0
func NewErrorMonitor(config ErrorMonitorConfig) (*debugmonitor.Monitor, ErrorRecorder)
NewErrorMonitor creates a new monitor for errors and returns the monitor along with an error recording function
type LogMonitorConfig ¶ added in v5.1.0
type LogMonitorConfig struct {
// Logger is the original slog.Logger whose handler will be wrapped.
// If nil, slog.Default() is used.
Logger *slog.Logger
// Skipper defines a function to skip recording a log entry.
// Optional. Default: never skip.
// Useful for excluding middleware.RequestLogger entries
// (messages "REQUEST" / "REQUEST_ERROR"), which belong in RequestMonitor.
Skipper LogSkipper
// UsePolling enables polling mode instead of SSE for real-time updates.
UsePolling bool
}
LogMonitorConfig defines the config for Log monitor.
type LogPayload ¶
type LogPayload struct {
Level string `json:"level"`
Message string `json:"message"`
Timestamp time.Time `json:"timestamp"`
}
LogPayload represents the data structure for log monitoring
type LogSkipper ¶ added in v5.1.0
LogSkipper defines a function to skip recording a log entry. Return true to skip collecting the log into the monitor. The underlying logger still receives the log.
type QueryMonitorConfig ¶ added in v5.1.0
type QueryMonitorConfig struct {
// DSN is the data source name for the database connection.
DSN string
// Driver is the database driver to wrap with monitoring.
Driver driver.Driver
// UsePolling enables polling mode instead of SSE for real-time updates.
UsePolling bool
}
QueryMonitorConfig defines the config for Query monitor.
type QueryPayload ¶
type QueryPayload struct {
Query string `json:"query"`
Args []interface{} `json:"args,omitempty"`
Duration int64 `json:"duration"` // in milliseconds
Error string `json:"error,omitempty"`
Timestamp time.Time `json:"timestamp"`
Operation string `json:"operation"` // Query, Exec, Prepare, Begin, Commit, Rollback
}
QueryPayload represents the data structure for database query monitoring
type RequestMonitorConfig ¶ added in v5.1.0
type RequestMonitorConfig struct {
// Skipper defines a function to skip middleware.
// Optional. Default: DefaultSkipper
Skipper middleware.Skipper
// UsePolling enables polling mode instead of SSE for real-time updates.
UsePolling bool
}
RequestMonitorConfig defines the config for Request monitor.
type RequestPayload ¶
type RequestPayload struct {
Method string `json:"method"`
URI string `json:"uri"`
Status int `json:"status"`
Latency int64 `json:"latency"` // in milliseconds
RemoteAddr string `json:"remoteAddr"`
UserAgent string `json:"userAgent"`
Error string `json:"error,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
RequestPayload represents the data structure for HTTP request monitoring
type WriterMonitorConfig ¶
type WriterMonitorConfig struct {
// Writer is the original io.Writer to write to.
Writer io.Writer
// UsePolling enables polling mode instead of SSE for real-time updates.
UsePolling bool
}
WriterMonitorConfig is the configuration for the writer monitor.
type WriterPayload ¶
type WriterPayload struct {
Data string `json:"data"`
}