Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector accumulates query records in a fixed-size ring buffer.
func NewCollector ¶
NewCollector creates a new collector with the given max buffer size.
func (*Collector) Add ¶
func (c *Collector) Add(r QueryRecord)
Add inserts a record into the ring buffer.
func (*Collector) Records ¶
func (c *Collector) Records() []QueryRecord
Records returns a snapshot of all collected records (newest first).
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin is a GORM plugin that records every query into a Collector.
type QueryRecord ¶
type QueryRecord struct {
Table string `json:"table"`
Operation string `json:"operation"`
SQL string `json:"sql"`
Duration time.Duration `json:"duration_ns"`
DurationMS float64 `json:"duration_ms"`
RowsAffected int64 `json:"rows_affected"`
ResponseSize int `json:"response_size"`
PreloadCount int `json:"preload_count"`
Timestamp time.Time `json:"timestamp"`
Error string `json:"error,omitempty"`
Caller string `json:"caller"`
DBType string `json:"db_type"`
Source string `json:"source"`
Endpoint string `json:"endpoint"`
}
QueryRecord holds the captured data for a single query execution.
Click to show internal directories.
Click to hide internal directories.