Skip to content

Commit 708bfa8

Browse files
committed
Revert "Enhance PBM backup metrics collection with detailed logging and improved metric creation"
This reverts commit 5642f84.
1 parent 5642f84 commit 708bfa8

File tree

1 file changed

+13
-60
lines changed

1 file changed

+13
-60
lines changed

exporter/pbm_collector.go

Lines changed: 13 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,8 @@ const (
5151

5252
func createPBMMetric(name, help string, value float64, labels map[string]string) prometheus.Metric { //nolint:ireturn
5353
const prefix = "mongodb_pbm_"
54-
55-
// Log what we're creating
56-
fullName := prefix + name
57-
58-
// Create the descriptor with labels as constant labels (4th parameter)
59-
d := prometheus.NewDesc(fullName, help, nil, labels)
60-
61-
// Create the metric
62-
metric := prometheus.MustNewConstMetric(d, prometheus.GaugeValue, value)
63-
64-
return metric
54+
d := prometheus.NewDesc(prefix+name, help, nil, labels)
55+
return prometheus.MustNewConstMetric(d, prometheus.GaugeValue, value)
6556
}
6657

6758
func newPbmCollector(ctx context.Context, client *mongo.Client, mongoURI string, logger *slog.Logger) *pbmCollector {
@@ -184,49 +175,27 @@ func (p *pbmCollector) pbmAgentMetrics(ctx context.Context, pbmClient *sdk.Clien
184175
}
185176

186177
func (p *pbmCollector) pbmBackupsMetrics(ctx context.Context, pbmClient *sdk.Client, l *slog.Logger) []prometheus.Metric {
187-
l.Info("===== Starting PBM backups metrics collection =====")
188-
189178
currentNode, err := util.MyRole(ctx, p.base.client)
190179
if err != nil {
191180
l.Error("failed to get current node info", "error", err.Error())
192181
return nil
193182
}
194-
l.Info("Current node info", "me", currentNode.Me, "is_master", currentNode.IsMaster, "is_secondary", currentNode.Secondary, "primary", currentNode.Primary)
195183

196184
backupsList, err := pbmClient.GetAllBackups(ctx)
197185
if err != nil {
198186
l.Error("failed to get PBM backup list", "error", err.Error())
199187
return nil
200188
}
201-
l.Info("Retrieved backups list", "total_backups", len(backupsList))
202189

203190
metrics := make([]prometheus.Metric, 0, len(backupsList))
204191

205-
for idx, backup := range backupsList {
206-
l.Info("===== Processing backup =====",
207-
"backup_index", idx,
208-
"name", backup.Name,
209-
"opid", backup.OPID,
210-
"status", backup.Status,
211-
"size", backup.Size,
212-
"replsets_count", len(backup.Replsets))
213-
192+
for _, backup := range backupsList {
214193
// Iterate through replsets in the backup metadata
215-
for i, replset := range backup.Replsets {
216-
l.Info("--- Processing replset ---",
217-
"replset_index", i,
218-
"replset_name", replset.Name,
219-
"replset_node", replset.Node)
220-
194+
for _, replset := range backup.Replsets {
221195
// Determine if this is the current node
222196
self := "0"
223197
if replset.Node == currentNode.Me {
224-
l.Info("This replset node matches current node", "node", replset.Node)
225198
self = "1"
226-
} else {
227-
l.Info("This replset node does NOT match current node",
228-
"replset_node", replset.Node,
229-
"current_node", currentNode.Me)
230199
}
231200

232201
labels := map[string]string{
@@ -238,28 +207,16 @@ func (p *pbmCollector) pbmBackupsMetrics(ctx context.Context, pbmClient *sdk.Cli
238207
"self": self,
239208
}
240209

241-
l.Info("Created labels map for backup metrics")
242-
l.Info(" Label: opid", "value", labels["opid"])
243-
l.Info(" Label: status", "value", labels["status"])
244-
l.Info(" Label: name", "value", labels["name"])
245-
l.Info(" Label: host", "value", labels["host"])
246-
l.Info(" Label: replica_set", "value", labels["replica_set"])
247-
l.Info(" Label: self", "value", labels["self"])
248-
249-
l.Info("Creating backup_size_bytes metric", "size", backup.Size)
250-
metric1 := createPBMMetric("backup_size_bytes",
210+
metrics = append(metrics, createPBMMetric("backup_size_bytes",
251211
"Size of PBM backup",
252-
float64(backup.Size), labels)
253-
metrics = append(metrics, metric1)
254-
l.Info("Added backup_size_bytes metric", "total_metrics", len(metrics))
212+
float64(backup.Size), labels),
213+
)
255214

256215
// Add backup_last_transition_ts metric
257-
l.Info("Creating backup_last_transition_ts metric", "timestamp", backup.LastTransitionTS)
258-
metric2 := createPBMMetric("backup_last_transition_ts",
216+
metrics = append(metrics, createPBMMetric("backup_last_transition_ts",
259217
"Last transition timestamp of PBM backup (seconds since epoch)",
260-
float64(backup.LastTransitionTS), labels)
261-
metrics = append(metrics, metric2)
262-
l.Info("Added backup_last_transition_ts metric", "total_metrics", len(metrics))
218+
float64(backup.LastTransitionTS), labels),
219+
)
263220

264221
var endTime int64
265222
switch pbmAgentStatus(backup.Status) {
@@ -270,16 +227,12 @@ func (p *pbmCollector) pbmBackupsMetrics(ctx context.Context, pbmClient *sdk.Cli
270227
}
271228

272229
duration := time.Unix(endTime-backup.StartTS, 0).Unix()
273-
l.Info("Creating backup_duration_seconds metric", "duration", duration, "start_ts", backup.StartTS, "end_time", endTime)
274-
metric3 := createPBMMetric("backup_duration_seconds",
230+
metrics = append(metrics, createPBMMetric("backup_duration_seconds",
275231
"Duration of PBM backup",
276-
float64(duration), labels)
277-
metrics = append(metrics, metric3)
278-
l.Info("Added backup_duration_seconds metric", "total_metrics", len(metrics))
232+
float64(duration), labels),
233+
)
279234
}
280235
}
281-
282-
l.Info("===== Finished PBM backups metrics collection =====", "total_metrics_created", len(metrics))
283236
return metrics
284237
}
285238

0 commit comments

Comments
 (0)