Skip to content

Commit

Permalink
PMM-12522 Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
BupycHuk committed May 13, 2024
1 parent 1f00e69 commit 38e3f52
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 13 deletions.
2 changes: 1 addition & 1 deletion exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (e *Exporter) getClient(ctx context.Context) (*mongo.Client, error) {
return client, nil
}

// Handler returns a http.Handler that serves metrics. Can be used instead of
// Handler returns an http.Handler that serves metrics. Can be used instead of
// run for hooking up custom HTTP servers.
func (e *Exporter) Handler() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion exporter/general_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (d *generalCollector) collect(ch chan<- prometheus.Metric) {
ch <- mongodbUpMetric(d.ctx, d.base.client, d.base.logger)
}

func mongodbUpMetric(ctx context.Context, client *mongo.Client, log *logrus.Entry) prometheus.Metric {
func mongodbUpMetric(ctx context.Context, client *mongo.Client, log *logrus.Entry) prometheus.Metric { //nolint:ireturn
var value float64

if client != nil {
Expand Down
2 changes: 0 additions & 2 deletions exporter/shards_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,13 @@ func (d *shardsCollector) collect(ch chan<- prometheus.Metric) {
ctx := d.ctx

metrics := make([]prometheus.Metric, 0)
logger.Debugf("chunksTotal")
metric, err := chunksTotal(ctx, client)
if err != nil {
logger.Warnf("cannot create metric for chunks total: %s", err)
} else {
metrics = append(metrics, metric)
}

logger.Debugf("chunksTotalPerShard")
ms, err := chunksTotalPerShard(ctx, client)
if err != nil {
logger.Warnf("cannot create metric for chunks total per shard: %s", err)
Expand Down
9 changes: 0 additions & 9 deletions exporter/v1_compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -1088,60 +1088,51 @@ func replSetMetrics(m bson.M) []prometheus.Metric {
func mongosMetrics(ctx context.Context, client *mongo.Client, l *logrus.Entry) []prometheus.Metric {
metrics := make([]prometheus.Metric, 0)

l.Debugf("databasesTotalPartitioned")
if metric, err := databasesTotalPartitioned(ctx, client); err != nil {
l.Debugf("cannot create metric for database total: %s", err)
} else {
metrics = append(metrics, metric)
}

l.Debugf("databasesTotalUnpartitioned")
if metric, err := databasesTotalUnpartitioned(ctx, client); err != nil {
l.Debugf("cannot create metric for database total: %s", err)
} else {
metrics = append(metrics, metric)
}

l.Debugf("shardedCollectionsTotal")
if metric, err := shardedCollectionsTotal(ctx, client); err != nil {
l.Debugf("cannot create metric for collections total: %s", err)
} else {
metrics = append(metrics, metric)
}

l.Debugf("balancerEnabled")
if metric, err := balancerEnabled(ctx, client); err != nil {
l.Debugf("cannot create metric for balancer is enabled: %s", err)
} else {
metrics = append(metrics, metric)
}

l.Debugf("chunksBalancerRunning")
if metric, err := chunksBalancerRunning(ctx, client); err != nil {
l.Debugf("cannot create metric for chunks balancer running: %s", err)
} else {
metrics = append(metrics, metric)
}

l.Debugf("shardingShardsTotal")
ms, err := changelog10m(ctx, client, l)
if err != nil {
l.Errorf("cannot create metric for changelog: %s", err)
} else {
metrics = append(metrics, ms...)
}

l.Debugf("dbstatsMetrics")
metrics = append(metrics, dbstatsMetrics(ctx, client, l)...)

l.Debugf("shardingShardsTotal")
if metric, err := shardingShardsTotal(ctx, client); err != nil {
l.Debugf("cannot create metric for database total: %s", err)
} else {
metrics = append(metrics, metric)
}

l.Debugf("shardingShardsDrainingTotal")
if metric, err := shardingShardsDrainingTotal(ctx, client); err != nil {
l.Debugf("cannot create metric for database total: %s", err)
} else {
Expand Down

0 comments on commit 38e3f52

Please sign in to comment.