Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-12989 Reduce error logs from diagnostic data on arbiter nodes #820

Merged
merged 31 commits into from
May 29, 2024

Conversation

idoqo
Copy link
Contributor

@idoqo idoqo commented Mar 18, 2024

PMM-12989 (optional, if ticket reported)


Below we provide a basic checklist of things that would make it a good PR:

  • Make sure to sign the CLA (Contributor License Agreement).
  • Make sure all tests pass.
  • Keep current with the target branch and fix conflicts if necessary.
  • Update jira ticket description if necessary.
  • Attach screenshots and/or console output to the jira ticket to confirm new behavior, if applicable.
  • Leave notes to the reviewers if you need to focus their attention on something specific.

Once all checks pass and the code is ready for review, please add pmm-review-exporters team as the reviewer. That would assign people from the review team automatically. Report any issues on our Forum.

@idoqo idoqo requested a review from a team as a code owner March 18, 2024 01:55
@idoqo idoqo requested review from BupycHuk and JiriCtvrtka and removed request for a team March 18, 2024 01:55
exporter/exporter_test.go Outdated Show resolved Hide resolved
@idoqo idoqo marked this pull request as draft March 18, 2024 02:30
exporter/diagnostic_data_collector_test.go Outdated Show resolved Hide resolved
exporter/diagnostic_data_collector_test.go Outdated Show resolved Hide resolved
exporter/diagnostic_data_collector_test.go Outdated Show resolved Hide resolved
exporter/diagnostic_data_collector_test.go Show resolved Hide resolved
@idoqo idoqo force-pushed the PMM-12989-arbiter-error-logs branch from 479139d to 3ed4e27 Compare April 8, 2024 10:24
@idoqo idoqo marked this pull request as ready for review April 9, 2024 09:29
Comment on lines +94 to +95
- 3 Instances for shard 1 at ports 17001, 17002, 17003 (with no authentication)
- 3 instances for shard 2 at ports 17004, 17005, 17006 (with authentication enabled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

logger.Errorf("failed to run command: getCmdLineOptions: %s", err)
} else if securityMetric != nil {
metrics = append(metrics, securityMetric)
}
}

if d.compatibleMode {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this point m might be empty, so it makes not much sense to call lines https://github.com/percona/mongodb_exporter/pull/820/files#diff-f08bb8e2230b960e7f7941dbdf020e3aa607391de1dc0f8683c315265d77b2f6R112-R116
I would include them to else part of the statement above

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW can we get diagnostic data from mongos?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW can we get diagnostic data from mongos?

No actually, the command won't fail, but m["data"] will be empty.

Comment on lines 818 to 820
if engine, err := storageEngine(m); err != nil {
l.Errorf("cannot retrieve engine type: %s", err)
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we know when we can't retrieve engine? it's important to not just hide an error, but hide it only for reason.

metrics = append(metrics, hm...)
}
} else {
if nodeType != typeArbiter {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci-lint] reported by reviewdog 🐶
if nodeType != typeArbiter has complex nested blocks (complexity: 5) (nestif)

@@ -782,7 +782,7 @@
}
}

func specialMetrics(ctx context.Context, client *mongo.Client, m bson.M, l *logrus.Logger) []prometheus.Metric {
func specialMetrics(ctx context.Context, client *mongo.Client, m bson.M, nodeType mongoDBNodeType, l *logrus.Logger) []prometheus.Metric {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci-lint] reported by reviewdog 🐶
calculated cyclomatic complexity for function specialMetrics is 12, max is 10 (cyclop)

@idoqo idoqo force-pushed the PMM-12989-arbiter-error-logs branch from 4f1f516 to 5dd6a44 Compare May 27, 2024 07:59
@@ -782,7 +782,7 @@ func specialMetricDefinitions() []specialMetric {
}
}

func specialMetrics(ctx context.Context, client *mongo.Client, m bson.M, l *logrus.Logger) []prometheus.Metric {
func specialMetrics(ctx context.Context, client *mongo.Client, m bson.M, nodeType mongoDBNodeType, l *logrus.Logger) []prometheus.Metric {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci-lint] reported by reviewdog 🐶
calculated cyclomatic complexity for function specialMetrics is 11, max is 10 (cyclop)

var metrics []prometheus.Metric
cmd := bson.D{{Key: "getDiagnosticData", Value: "1"}}
res := client.Database("admin").RunCommand(d.ctx, cmd)
if nodeType != typeArbiter {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci-lint] reported by reviewdog 🐶
if nodeType != typeArbiter has complex nested blocks (complexity: 16) (nestif)

@@ -782,7 +782,7 @@ func specialMetricDefinitions() []specialMetric {
}
}

func specialMetrics(ctx context.Context, client *mongo.Client, m bson.M, l *logrus.Entry) []prometheus.Metric {
func specialMetrics(ctx context.Context, client *mongo.Client, m bson.M, nodeType mongoDBNodeType, l *logrus.Entry) []prometheus.Metric {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci-lint] reported by reviewdog 🐶
calculated cyclomatic complexity for function specialMetrics is 11, max is 10 (cyclop)

@BupycHuk BupycHuk merged commit 28e85f3 into main May 29, 2024
7 checks passed
@BupycHuk BupycHuk deleted the PMM-12989-arbiter-error-logs branch May 29, 2024 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants