-
Notifications
You must be signed in to change notification settings - Fork 130
Conversation
… specific categories.
…hings up so plugins can register their own metric categories in the future.
public boolean isPantheonSpecific() { | ||
return pantheonSpecific; | ||
} | ||
boolean isApplicationSpecific(); |
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.
Instead of having a boolean
here + the applicationPrefix
configured on the MetricsSystem
, what about just storing an Optional<String> applicationPrefix
on MetricsCategory
?
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 was skeptical at first but have come around. This does simplify things and given an application would typically have one enum for its categories it actually works out pretty nicely.
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.
Looks reasonable. It's hard to find the real changes with all the interface renaming.
Agreed, I'll split it up into a couple of separate PRs to make things clearly - it took a bit of playing to work out what the final destination needed to look like. |
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.
LGTM
@@ -650,6 +653,11 @@ public void parse( | |||
commandLine.registerConverter(Wei.class, (arg) -> Wei.of(Long.parseUnsignedLong(arg))); | |||
commandLine.registerConverter(PositiveNumber.class, PositiveNumber::fromString); | |||
|
|||
final MetricCategoryConverter metricCategoryConverter = new MetricCategoryConverter(); | |||
metricCategoryConverter.addCategories(PantheonMetricCategory.class); | |||
metricCategoryConverter.addCategories(StandardMetricCategory.class); |
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 may want to expose this via the plugin APIs, but we should wait until some plugin wants it.
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.
Yep agreed.
PR description
Artemis have expressed interest in using our metrics library since they'll need to export to Prometheus but don't necessarily want to be tied to it and want to avoid the very static-heavy approach the Prometheus client library normally uses.
Currently there are a few Pantheon specific details that have leaked into the metrics library - the hardcoded
pantheon_
prefix andMetricCategories
being an enum full of categories specifically for Pantheon.Having
MetricCategories
as an enum also prevents future plugins from adding their own categories if we add a metrics service to our plugin APIs.So there are four major changes in this PR (once we've agreed on the final design we're heading towards I can break it up into smaller PRs to simplify reviews):
MetricCategory
an interface instead of an enum. This required getting rid of most usages ofEnumSet
in favour of a plainSet
. There are now two enums which implementMetricCategory
,StandardMetricCategory
(JVM and PROCESS) which should stay in the metrics package andPantheonMetricCategory
which needs to find a home outside of the metric package since it's Pantheon specific (not sure where yet).PantheonCommand
builds up a map of allowed metric category names to their instances. Currently that's just aHashMap
which all the values fromStandardMetricCategory
andPantheonMetricCategory
are added into. A plugin API could be exposed to allow plugins to register their own categories in the future.util
. This was only used in production code to check the network port was valid so I just inlined it. The tests still have a dependency on it for one method but that won't affect other projects trying to import the metrics library.Open questions/ugly bits:
PantheonMetricCategory
actually live. It needs to be available to most of Pantheon. May need to just create a:metrics:pantheon
module specifically for it, although its slightly tempting to shove it intoutil
...PantheonCommand
to register the metric categories doesn't feel particularly clean. Might be able to extract a class to clean it up.MetricSystem
doesn't actually check that theMetricCategory
supplied when creating a counter/gauge/etc was actually registered back inPantheonCommand
, although if it wasn't it will just never be enabled.