Documentation
¶
Index ¶
- Variables
- type MongoMonitor
- func (m *MongoMonitor) AddCommandMonitorFailedFunc(commandFunc func(context.Context, *event.CommandFailedEvent))
- func (m *MongoMonitor) AddCommandMonitorStartedFunc(commandFunc func(context.Context, *event.CommandStartedEvent))
- func (m *MongoMonitor) AddCommandMonitorSucceededFunc(commandFunc func(context.Context, *event.CommandSucceededEvent))
- func (m *MongoMonitor) AddPoolMonitorFunc(poolEvent func(evt *event.PoolEvent))
- func (m *MongoMonitor) GetCommandMonitor() *event.CommandMonitor
- func (m *MongoMonitor) GetPoolMonitor() *event.PoolMonitor
- func (m *MongoMonitor) RegistryMetrics(registry *prometheus.Registry) error
- type NewMetricsOptions
Constants ¶
This section is empty.
Variables ¶
var DefaultMetricsOptions = &NewMetricsOptions{ PoolEventMetricsCounterName: "mongo_pool_event_total", ConnectionMetricsGaugeName: "mongo_pool_connection", CommandDurationBucketName: "mongo_command_duration", commandDurationBucket: []float64{0.0001, 0.001, 0.01, 0.05, 0.1, 0.5, 0.8, 1, 2, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600}, LogInfoFunc: nil, LogWarnFunc: nil, }
Functions ¶
This section is empty.
Types ¶
type MongoMonitor ¶
type MongoMonitor struct {
// contains filtered or unexported fields
}
func NewMongoMonitor ¶
func NewMongoMonitor(newMetricsOpt *NewMetricsOptions) *MongoMonitor
NewMongoMonitor create a new mongo monitor, it can generator monitor func for mongo-go-driver monitor
func (*MongoMonitor) AddCommandMonitorFailedFunc ¶
func (m *MongoMonitor) AddCommandMonitorFailedFunc(commandFunc func(context.Context, *event.CommandFailedEvent))
AddCommandMonitorFailedFunc add commandFailedFunc to the monitorFailedFuncChain. when mongo command failed monitor func is triggered, custom func will also be executed after default metrics func.
func (*MongoMonitor) AddCommandMonitorStartedFunc ¶
func (m *MongoMonitor) AddCommandMonitorStartedFunc(commandFunc func(context.Context, *event.CommandStartedEvent))
AddCommandMonitorStartedFunc add commandStartedFunc to the monitorStartedFuncChain. when mongo command started monitor func is triggered, custom func will also be executed after default metrics func.
func (*MongoMonitor) AddCommandMonitorSucceededFunc ¶
func (m *MongoMonitor) AddCommandMonitorSucceededFunc(commandFunc func(context.Context, *event.CommandSucceededEvent))
AddCommandMonitorSucceededFunc add commandSucceededFunc to the monitorSucceededFuncChain. when mongo command succeeded monitor func is triggered, custom func will also be executed after default metrics func.
func (*MongoMonitor) AddPoolMonitorFunc ¶
func (m *MongoMonitor) AddPoolMonitorFunc(poolEvent func(evt *event.PoolEvent))
AddPoolMonitorFunc add a poolMonitorFunc to the poolMonitorFuncChain. when mongo pool monitor func is triggered, custom func will also be executed after default metrics func.
func (*MongoMonitor) GetCommandMonitor ¶
func (m *MongoMonitor) GetCommandMonitor() *event.CommandMonitor
GetCommandMonitor return a commandMonitor for mongo-go-driver monitor
func (*MongoMonitor) GetPoolMonitor ¶
func (m *MongoMonitor) GetPoolMonitor() *event.PoolMonitor
GetPoolMonitor return a poolMonitor for mongo-go-driver monitor
func (*MongoMonitor) RegistryMetrics ¶
func (m *MongoMonitor) RegistryMetrics(registry *prometheus.Registry) error
RegistryMetrics register all metrics to prometheus registry.
type NewMetricsOptions ¶
type NewMetricsOptions struct { PoolEventMetricsCounterName string // PoolEventMetricsCounterName name of event metric. default: mongo_pool_event_total ConnectionMetricsGaugeName string // ConnectionMetricsGaugeName name of connection metric. default: mongo_pool_connection CommandDurationBucketName string // CommandDurationBucketName name of command duration bucket metric. default: mongo_command_duration_bucket LogInfoFunc func(format string, args ...any) // LogInfoFunc LogWarnFunc func(format string, args ...any) // LogWarnFunc // contains filtered or unexported fields }
NewMetricsOptions is the options for NewMetricsMonitor it can be used to set the name of metrics or the log function defaultOptions will be used if field not set