Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func parseFlags() (*Config, error) {
if err != nil {
return nil, err
}
initMonitoring(opts, statsdClient, loggerClient, enableSdamMetrics, enableSdamLogging)
initMonitoring(label, opts, statsdClient, loggerClient, enableSdamMetrics, enableSdamLogging)
clients = append(clients, client{
address: address,
label: label,
Expand Down Expand Up @@ -253,9 +253,9 @@ func clientOptions(uri, username, password string) (string, *options.ClientOptio
return label, opts, nil
}

func initMonitoring(opts *options.ClientOptions, statsd *statsd.Client, logger *zap.Logger, enableSdamMetrics bool, enableSdamLogging bool) *options.ClientOptions {
func initMonitoring(label string, opts *options.ClientOptions, statsd *statsd.Client, logger *zap.Logger, enableSdamMetrics bool, enableSdamLogging bool) *options.ClientOptions {
// set up monitors for Pool and Server(SDAM)
opts = opts.SetPoolMonitor(poolMonitor(statsd))
opts = opts.SetPoolMonitor(poolMonitor(label, statsd))
opts = opts.SetServerMonitor(serverMonitoring(logger, statsd, enableSdamMetrics, enableSdamLogging))
return opts
}
Expand Down Expand Up @@ -302,9 +302,14 @@ func newLogger(level zapcore.Level, pretty bool) *zap.Logger {
return log
}

func poolMonitor(sd *statsd.Client) *event.PoolMonitor {
checkedOut, checkedIn := util.StatsdBackgroundGauge(sd, "pool.checked_out_connections", []string{})
opened, closed := util.StatsdBackgroundGauge(sd, "pool.open_connections", []string{})
func poolMonitor(label string, sd *statsd.Client) *event.PoolMonitor {
defaultTags := []string{}
if label != "" {
defaultTags = append(defaultTags, fmt.Sprintf("cluster:%s", label))
}

checkedOut, checkedIn := util.StatsdBackgroundGauge(sd, "pool.checked_out_connections", defaultTags)
opened, closed := util.StatsdBackgroundGauge(sd, "pool.open_connections", defaultTags)

return &event.PoolMonitor{
Event: func(e *event.PoolEvent) {
Expand All @@ -314,6 +319,8 @@ func poolMonitor(sd *statsd.Client) *event.PoolMonitor {
fmt.Sprintf("address:%s", e.Address),
fmt.Sprintf("reason:%s", e.Reason),
}
tags = append(tags, defaultTags...)

switch e.Type {
case event.ConnectionCreated:
opened(name, tags)
Expand Down