-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Upgrade Mongodb library in Beats to v5 #31185
Upgrade Mongodb library in Beats to v5 #31185
Conversation
This pull request is now in conflicts. Could you fix it? 🙏
|
…mb/upgrade-mongodb-library # Conflicts: # go.mod # go.sum # metricbeat/module/mongodb/collstats/collstats.go # metricbeat/module/mongodb/dbstats/dbstats.go # metricbeat/module/mongodb/replstatus/data.go # metricbeat/module/mongodb/replstatus/replstatus_integration_test.go # metricbeat/module/mongodb/status/status.go
/test |
// As a minimum it must inherit the mb.BaseMetricSet fields, but can be extended with | ||
// additional entries. These variables can be used to persist data or configuration between | ||
// multiple fetch calls. | ||
type MetricSet struct { | ||
*mongodb.MetricSet | ||
type Metricset struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for this name change? There appears to be disagreement in the code base about how this should be spelled; the docs spell it as a single word, but the mb package spells it as a camel-cased pair.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I'm afraid that it's out of the scope of the PR to reach a consensus 🙂 Personally I don't like the camelCased version and I think statistically you'll see it more often without camelCase like in the docs of most of the metricsets of most of the modules. https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-metricset-mongodb-collstats.html
defer func() { | ||
_ = client.Disconnect(context.Background()) | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be an unpopular opinion, but I think assigning to the blank identifier to satisfy the linter is an antipattern; it does not handle the error but also evades the rationale behind enforcing require-explanation: true
and makes it harder in the future to clean up linter supression because it is harder to find and reason about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, I'd rather see an explanation of why errors can be ignored where possible using the //nolint:errcheck $reason
comment instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On top of my head, most of Close
and Disconnect
operations across metricbeat modules ignores the error. As the person who has tried to maintain this module on the last years, I just wanted to do the dirty work of upgrading the library and leave improvements to the @elastic/obs-service-integrations team now
Keep in mind that it takes me more time to write this message on GH than to write a line that logs the error.
Thanks for the messages, it will be nice if @efd6 can take a quick look at the Packetbeat file that was modified in this PR, that's why security was pinged. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Packetbeat changes are fine.
This pull request is now in conflicts. Could you fix it? 🙏
|
…mb/upgrade-mongodb-library # Conflicts: # metricbeat/module/mongodb/dbstats/dbstats.go # metricbeat/module/mongodb/metricset.go # metricbeat/module/mongodb/mongodb.go # packetbeat/protos/mongodb/mongodb_parser.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested for the compatibility for MongoDB version 5.0 and >5.0 and beat managed establish the connection and pull the metrics.
As discussed please close the related issue for mongo DB. Rest LGTM.
@@ -24,40 +24,40 @@ import ( | |||
|
|||
var schema = s.Schema{ | |||
"db": c.Str("db"), | |||
"collections": c.Int("collections"), | |||
"objects": c.Int("objects"), | |||
"collections": c.Ifc("collections"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sayden Is this also part of this driver update change? Can you please let us know in brief for the change from Int to Ifc() .
This pull request is now in conflicts. Could you fix it? 🙏
|
This pull request is now in conflicts. Could you fix it? 🙏
|
…mb/upgrade-mongodb-library # Conflicts: # go.sum # metricbeat/module/mongodb/metricset.go
"github.com/elastic/elastic-agent-libs/mapstr" | ||
) | ||
|
||
func TestFetch(t *testing.T) { | ||
t.Skip("Flaky test: https://github.com/elastic/beats/issues/29208") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is flaky again: #31768
What does this PR do?
Replaces Mongodb library that Beats was using for the updated (and maintained) official version.
Why is it important?
Current version library was unmaintained and Beats could only support up to v3.2. This change adds support for V4 and V5 too.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.