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

Adding query APIs for metricsets and modules from metricbeat registry #4102

Merged
merged 2 commits into from
Apr 25, 2017

Conversation

vjsamuel
Copy link
Contributor

No description provided.

@vjsamuel vjsamuel force-pushed the add_metricsets_registry_query branch from df914a4 to 28148ad Compare April 24, 2017 22:54
@elasticmachine
Copy link
Collaborator

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
@elasticmachine
Copy link
Collaborator

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.

@vjsamuel vjsamuel force-pushed the add_metricsets_registry_query branch from 28148ad to bb850bf Compare April 24, 2017 23:43
@@ -6,6 +6,7 @@ import (
"strings"

"github.com/elastic/beats/libbeat/logp"
"sync"
Copy link
Member

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

@ruflin ruflin requested a review from andrewkroh April 25, 2017 07:33
r.RLock()
defer r.RUnlock()

modules := []string{}
Copy link
Member

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.

r.RLock()
defer r.RUnlock()

metricsets := []string{}
Copy link
Member

Choose a reason for hiding this comment

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


sets, ok := r.metricSets[module]
if ok {
for name := range sets {
Copy link
Member

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).

@@ -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
Copy link
Member

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 //.

@@ -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
Copy link
Member

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."`.

@andrewkroh
Copy link
Member

jenkins, test it

@andrewkroh andrewkroh merged commit 354fdd6 into elastic:master Apr 25, 2017
@vjsamuel vjsamuel deleted the add_metricsets_registry_query branch May 2, 2017 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants