-
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
Metricbeat: Add configuration for RabbitMQ management prefix path #7074
Conversation
metricbeat/module/rabbitmq/url.go
Outdated
) | ||
|
||
var ( | ||
HostParser = parse.URLHostParserBuilder{ |
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.
exported var HostParser should have comment or be unexported
metricbeat/module/rabbitmq/url.go
Outdated
defaultScheme = "http" | ||
pathConfigKey = "management_path_prefix" | ||
|
||
ConnectionsPath = "/api/connections" |
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.
exported const ConnectionsPath should have comment (or a comment on this block) or be unexported
*helper.HTTP | ||
} | ||
|
||
func NewMetricSet(base mb.BaseMetricSet, subPath string) (*MetricSet, error) { |
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.
exported function NewMetricSet should have comment or be unexported
"github.com/elastic/beats/metricbeat/mb" | ||
) | ||
|
||
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.
exported type MetricSet should have comment or be unexported
metricbeat/helper/http.go
Outdated
@@ -103,6 +103,10 @@ func (h *HTTP) SetMethod(method string) { | |||
h.method = method | |||
} | |||
|
|||
func (h *HTTP) GetURI() 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.
exported method HTTP.GetURI should have comment or be unexported
f2fbb5b
to
40a3f2c
Compare
metricbeat/module/rabbitmq/url.go
Outdated
|
||
// Subpaths to management plugin endpoints | ||
ConnectionsPath = "/api/connections" | ||
ExchangesPath = "/api/exchanges" |
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.
exported const ExchangesPath should have comment (or a comment on this block) or be unexported
metricbeat/module/rabbitmq/url.go
Outdated
defaultScheme = "http" | ||
pathConfigKey = "management_path_prefix" | ||
|
||
// Subpaths to management plugin endpoints |
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.
comment on exported const ConnectionsPath should be of the form "ConnectionsPath ..."
e04c9c9
to
1c66840
Compare
Refactor RabbitMQ metricsets to reuse host parser and metricset builder so management prefix path can be configured as an only module setting. Check in tests the paths metricbeat is trying to access to collect the metrics. Previously it required to configure each metricset in its own module block with the path in the host.
1c66840
to
e91a07a
Compare
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 is a huge step forward in how we can simplify adding new modules. This will reduce the code in quite a few modules with multiple metricsets and will adding new ones much easier.
I was wondering if we should split out the code refactoring part from the management change? Not necessarily because of the management change but because I think the refactor deserves it's own commit to point people to to have a look.
@@ -14,13 +14,21 @@ import ( | |||
) | |||
|
|||
func TestFetchEventContents(t *testing.T) { | |||
absPath, err := filepath.Abs("../_meta/testdata/") | |||
absPath, _ := filepath.Abs("../_meta/testdata/") |
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 would add a assert.NoError( for these erors. This will make debugging test much easier.
w.Header().Set("Content-Type", "application/json;") | ||
w.Write([]byte(response)) | ||
default: | ||
w.WriteHeader(404) |
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.
Nice, I should steal this for my elasticsearch http tests.
func init() { | ||
if err := mb.Registry.AddMetricSet("rabbitmq", "exchange", New, hostParser); err != nil { |
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.
Did we miss that in our PR bonanza or this came in later?
|
||
// Subpaths to management plugin endpoints | ||
const ( | ||
ConnectionsPath = "/api/connections" |
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'm going forth an back if this should be in the module or in the metricset. Is there a benefit that the module knows about these paths?
|
||
var ( | ||
// HostParser parses host urls for RabbitMQ management plugin | ||
HostParser = parse.URLHostParserBuilder{ |
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 wonder if it could become an issue that all Metricsets will now share one host parser as a global object?
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.
It shouldn't be an issue.
Merged it already to move forward with this. I really hope we get similar simplifications for other modules. |
This is inspired by elastic#7074. More work is needed.
…astic#7074) Refactor RabbitMQ metricsets to reuse host parser and metricset builder so management prefix path can be configured as an only module setting. Check in tests the paths metricbeat is trying to access to collect the metrics. Previously it required to configure each metricset in its own module block with the path in the host.
…astic#7074) Refactor RabbitMQ metricsets to reuse host parser and metricset builder so management prefix path can be configured as an only module setting. Check in tests the paths metricbeat is trying to access to collect the metrics. Previously it required to configure each metricset in its own module block with the path in the host.
Refactor RabbitMQ metricsets to reuse host parser and metricset builder
so management prefix path can be configured as an only module setting.
Check in tests the paths metricbeat is trying to access to collect the
metrics.
Previously it required to configure each metricset in its own module
block with the path in the host, as described in #6875.