Documentation ¶
Index ¶
- Constants
- Variables
- func ExplainEnd(db *gorm.DB)
- func GetDuration(ctx context.Context) time.Duration
- func GetDurationMilliseconds(ctx context.Context) float64
- func GetStartTime(db *gorm.DB) time.Time
- func SetStartTime(db *gorm.DB)
- type Explain
- type ExplainPlugin
- type LogPlugin
- type MetricPlugin
- type StartTimePlugin
- type TracePlugin
Constants ¶
View Source
const (
TypeGorm = "gorm"
)
Variables ¶
View Source
var ( // ErrRecordNotFound record not found error, happens when haven't find any matched data when looking up with a struct ErrRecordNotFound = gorm.ErrRecordNotFound // ErrInvalidTransaction invalid transaction when you are trying to `Commit` or `Rollback` ErrInvalidTransaction = gorm.ErrInvalidTransaction )
View Source
var ( DBHandleHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Name: "db_handle_seconds", }, []string{"type", "name", "method", "peer"}) DBHandleCounter = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "db_handle_total", }, []string{"type", "name", "method", "peer", "code"}) DBStatsGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "db_stats", }, []string{"name", "type"}) )
Functions ¶
func ExplainEnd ¶
func GetDurationMilliseconds ¶
func SetStartTime ¶
Types ¶
type Explain ¶
type Explain struct { Id int64 `gorm:"column:id"` SelectType string `gorm:"column:select_type"` // 查询行为类型 simple primary union... Table string `gorm:"column:table"` // tableName Partitions string `gorm:"column:partitions"` // 分区 Type string `gorm:"column:type"` // 引擎层查询数据行为类型 system const ref index index_merge all ... PossibleKeys string `gorm:"column:possible_keys"` // 可能用到的所有索引 Key string `gorm:"column:key"` // 真正用到的所有索引 KeyLen int32 `gorm:"column:key_len"` // 查询时用到的索引长度 Ref string `gorm:"column:ref"` // 哪些列或常量与key所使用的字段进行比较 Rows int32 `gorm:"column:rows"` // 预估需要扫描的行数 Filtered float32 `gorm:"column:filtered"` // 根据条件过滤后剩余的行数百分比(预估) Extra string `gorm:"column:extra"` }
type ExplainPlugin ¶
type ExplainPlugin struct{}
func NewExplainPlugin ¶
func NewExplainPlugin() *ExplainPlugin
func NewMetricPlugin ¶
func NewMetricPlugin() *ExplainPlugin
func (*ExplainPlugin) Initialize ¶
func (e *ExplainPlugin) Initialize(db *gorm.DB) error
func (*ExplainPlugin) Name ¶
func (e *ExplainPlugin) Name() string
type LogPlugin ¶
type LogPlugin struct {
// contains filtered or unexported fields
}
func NewLogPlugin ¶
func NewLogPlugin(config *emysql_config.Config, dsn *manager.DSN) *LogPlugin
type MetricPlugin ¶
type MetricPlugin struct {
// contains filtered or unexported fields
}
func (*MetricPlugin) Initialize ¶
func (e *MetricPlugin) Initialize(db *gorm.DB) error
func (*MetricPlugin) Name ¶
func (e *MetricPlugin) Name() string
type StartTimePlugin ¶
type StartTimePlugin struct{}
func NewStartTimePlugin ¶
func NewStartTimePlugin() *StartTimePlugin
func (*StartTimePlugin) Initialize ¶
func (e *StartTimePlugin) Initialize(db *gorm.DB) error
func (*StartTimePlugin) Name ¶
func (e *StartTimePlugin) Name() string
type TracePlugin ¶
type TracePlugin struct {
// contains filtered or unexported fields
}
func NewTracePlugin ¶
func NewTracePlugin(dsn *manager.DSN) *TracePlugin
func (*TracePlugin) Initialize ¶
func (t *TracePlugin) Initialize(db *gorm.DB) error
func (*TracePlugin) Name ¶
func (t *TracePlugin) Name() string
func (*TracePlugin) TraceEnd ¶
func (t *TracePlugin) TraceEnd(db *gorm.DB)
func (*TracePlugin) TraceStart ¶
func (t *TracePlugin) TraceStart(db *gorm.DB)
Click to show internal directories.
Click to hide internal directories.