-
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
Adding query APIs for metricsets and modules from metricbeat registry #4102
Adding query APIs for metricsets and modules from metricbeat registry #4102
Conversation
df914a4
to
28148ad
Compare
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run. |
1 similar comment
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run. |
28148ad
to
bb850bf
Compare
metricbeat/mb/registry.go
Outdated
@@ -6,6 +6,7 @@ import ( | |||
"strings" | |||
|
|||
"github.com/elastic/beats/libbeat/logp" | |||
"sync" |
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 should be with strings
bb850bf
to
d53a0aa
Compare
metricbeat/mb/registry.go
Outdated
r.RLock() | ||
defer r.RUnlock() | ||
|
||
modules := []string{} |
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.
Change this to make([]string, 0, len(r.modules))
since it knows the capacity requirement a priori.
metricbeat/mb/registry.go
Outdated
r.RLock() | ||
defer r.RUnlock() | ||
|
||
metricsets := []string{} |
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.
Declare this as var metricsets []string
. https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices
metricbeat/mb/registry.go
Outdated
|
||
sets, ok := r.metricSets[module] | ||
if ok { | ||
for name := range sets { |
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.
Once it reaches this point, it can allocate the slice with the metricsets = make([]string, 0, len(sets)
.
metricbeat/mb/registry.go
Outdated
@@ -46,6 +47,8 @@ type metricSetFactoryInfo struct { | |||
// Register contains the factory functions for creating new Modules and new | |||
// MetricSets. | |||
type Register struct { | |||
//Lock to control concurrent read/writes |
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 comment needs a space after the //
.
metricbeat/mb/registry.go
Outdated
@@ -46,6 +47,8 @@ type metricSetFactoryInfo struct { | |||
// Register contains the factory functions for creating new Modules and new | |||
// MetricSets. | |||
type Register struct { | |||
//Lock to control concurrent read/writes | |||
sync.RWMutex |
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.
I think embedding the mutex is not a good choice here because the methods will be become part of Register
's public API. Users should never need to lock/unlock the Register
because that is handled internally.
This reminds me, can you add to the godoc for Register
that "It is safe for concurrent usage."`.
jenkins, test it |
No description provided.