Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback interface {
// contains filtered or unexported methods
}
Callback interface for query plugin
func ErrorQueryCallback ¶
SlowQueryCallback returns a Callback. And replace all kind of Callback with slow query stats function.
func NewCallback ¶
func NewCallback(f func(db *gorm.DB), cols ...prometheus.Collector) Callback
NewCallback return a Callback interface.
func SlowQueryCallback ¶
SlowQueryCallback returns a Callback. And replace all kind of Callback with slow query stats function.
type Config ¶
Config is for slow query option. Setting counter name, namespace and slow query threshold. It will stats when slow query execution timeQuery is over SlowThreshold, and store in counter and histogram in Namespace and with NamePrefix.
type Interceptor ¶
Interceptor function receives callback name, and return a function to wrap the Handler with next Handler.
type MetricPlugin ¶
type MetricPlugin interface { Name() string Initialize(db *gorm.DB) error MetricsCollectors() []prometheus.Collector }
MetricPlugin contains prometheus.Plugin interface, and MetricsCollectors function for register metrics in prometheus.
func New ¶
func New(opts ...Callback) MetricPlugin
New a query metric plugin which can monitor query timing