query

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2021 License: MIT Imports: 4 Imported by: 0

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

func ErrorQueryCallback(c Config) Callback

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

func SlowQueryCallback(c Config) Callback

SlowQueryCallback returns a Callback. And replace all kind of Callback with slow query stats function.

type Config

type Config struct {
	DBName        string
	Namespace     string
	NamePrefix    string
	SlowThreshold time.Duration
}

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 Handler

type Handler func(db *gorm.DB)

Handler is gorm v2 callback function

type Interceptor

type Interceptor func(string) func(next Handler) Handler

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL