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

Injectable metricsRegistry #263

Merged
merged 6 commits into from
Sep 6, 2018

Conversation

taer
Copy link
Contributor

@taer taer commented Aug 31, 2018

This allows the user to set the metrics registry instead of it being auto created.
Useful for Dependency Injection.

@mikkokar mikkokar requested review from dvlato, mikkokar and kvosper and removed request for dvlato and mikkokar September 3, 2018 08:25
*
* @return the metrics
*/
Map<String, Metric> getMetrics();
Copy link
Contributor

Choose a reason for hiding this comment

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

All other getters in this class return a SortedMap. This should too. At least for the sake of consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The underlying metrics registry returns a sortedMap in all those cases. So it's a pass through. The getMetrics though just returns a Collections.unmodifiableMap(metrics) Assuming you want this just sorted in the impl in this case.

@@ -53,6 +54,7 @@ public CodaHaleMetricRegistry() {
this(new com.codahale.metrics.MetricRegistry());
}

@JsonValue
public com.codahale.metrics.MetricRegistry getMetricRegistry() {
return metricRegistry;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this @JsonValue here to serialise the CodaHaleMetricRegistry instance?
Please consider providing a Mixin class instead. See com.hotels.styx.infrastructure.configuration.json.mixins as an example.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we need to remove the getMetricRegistry going forward. It exposes the implementation detail outside of the metrics interface. Ideally, a Coda Hale metrics registry required for Graphite & Jmx reporters would be bridged to Styx metrics registry.

But that is another story and I don't think necessary for this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are 2 ObjectMappers in the MetricsHandler. For the filtered one, it's declared at the top of the MetricsHandler. If not filtered, it defaults the the internal one in JsonHandler. I added a new module so I could send the mixin to that objectMapper

Robert Macaulay added 4 commits September 4, 2018 12:59
This allows the user to set the metrics registry instead of it being auto created.
Useful for Dependency Injection.
@mikkokar mikkokar merged commit 4e0ff6c into ExpediaGroup:master Sep 6, 2018
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.

2 participants