-
Notifications
You must be signed in to change notification settings - Fork 459
add low memory metric to abstract server #3288
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
Conversation
Fixes issue #3243 |
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 looks good, I'm glad that you added the new metric to one of the tests. I think you will also need to add the metric to the collection of unreported metrics in MetricsIT. Also, all of the classes that subclass AbstractServer (TabletServer, Manager, etc) call MetricsUtil.initializeProducers. I have not looked to see if there is an issue with calling it twice in the same process. I was originally thinking that in the subclasses of AbstractServer, we would just add this class as another producer to the list instead of calling it here too. Have you evaluated that already?
public void registerMetrics(MeterRegistry registry) { | ||
lowMemoryMetricGuage = | ||
Gauge | ||
.builder(METRICS_APP_PREFIX + applicationName + "." + hostname + "." |
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 not super familiar with Micrometer, but the way this is currently implemented, wouldn't
the metrics be created in the following structure?
accumulo.app.app1.server1.detected.low.memory = 1|0
accumulo.app.app1.server2.detected.low.memory = 1|0
accumulo.app.app2.server1.detected.low.memory = 1|0
I'm pretty sure these would all be considered unique metrics.
Does Micrometer support tags or metric labels?
If the application name and host name were added as tags on the metric, then the metric would look like
accumulo.app.detected.low.memory{"application Name": "app1", "hostname": "server1"} = 1|0
This drops the unique metric definition down to accumulo.app.detected.low.memory
and allows sorting and filtering based on application name
or hostname
.
Alerting still works by firing on accumulo.app.detected.low.memory =1
but better granularity is allowed on the visualization and alerting ends.
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.
There are tags - I'm trying to confirm that they are being set correctly as I look at Dave's other comments.
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 agree, I think we want something like accumulo.server.detected.low.memory
and the application name should be in a tag.
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.
Leveraged tags in 674a9da
core/src/main/java/org/apache/accumulo/core/metrics/MetricsProducer.java
Outdated
Show resolved
Hide resolved
server/base/src/main/java/org/apache/accumulo/server/AbstractServer.java
Outdated
Show resolved
Hide resolved
server/base/src/main/java/org/apache/accumulo/server/AbstractServer.java
Outdated
Show resolved
Hide resolved
@@ -602,7 +602,7 @@ public void run() { | |||
LOG.error("Error initializing metrics, metrics will not be emitted.", e1); | |||
} | |||
pausedMetrics = new PausedCompactionMetrics(); | |||
MetricsUtil.initializeProducers(this, pausedMetrics); | |||
initServerMetrics(pausedMetrics); |
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 this
was dropped accidentally. Compactor
implements MetricsProducer
too, so it's registerMetrics
method is not getting called.
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.
fixed in 49b93b3
processMetrics.registerMetrics(registry); | ||
} | ||
|
||
public void initServerMetrics(MetricsProducer... producers) { |
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 don't think this method is necessary, and it's initializing the metrics for AbstractServer differently than everything else. Since you have modified AbstractServer
to implement MetricsProducer
, then:
- You should have any subclasses of
AbstractServer
callsuper.registerMetrics
in their respectiveregisterMetrics
method. For example, Compactor.registerMetrics. - You should pass
this
in subclasses ofAbstractServer
in the call toMetricsUtil.initializeProducers
.
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.
@dlmarion What do you think is easier to understand? Classes that extended abstract server must call super.registerMetrics
or call a method 'initServerMetrics' ? Either way requires something that may not be obvious.
Because of the tagging, the registration / initialization needs to occur in the run method - and after certain things have been initialized (host and port)
I'm not thrilled with either approach, but went with a specific initServerMetrics
method - if relying on calling super.registerMetrics' and the needing to call the static
MetricsUtil.initializeProducerswhich results in an indirect call to
registerMetrics`?
I was thinking about moving the static initializeMetrics
out of MetricsUtil and put the functionality into AbstractServer - I think that functionality only applies to services extending AbstractServer.
The initializeProducers
functionality needs to exist to register metrics producers for things that are created outside of the AbstarctServer context (thrift metrics, cache,....) - but those are created / exist within a service context that has already been expected to initialize the registry.
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.
@dlmarion What do you think is easier to understand? Classes that extended abstract server must call
super.registerMetrics
or call a method 'initServerMetrics' ? Either way requires something that may not be obvious.
With Java, I think it's standard practice, or should be, for developers to evaluate whether or not the superclass method needs to be called when overriding a method.
Because of the tagging, the registration / initialization needs to occur in the run method - and after certain things have been initialized (host and port)
agreed
I'm not thrilled with either approach, but went with a specific
initServerMetrics
method - if relying on callingsuper.registerMetrics' and the needing to call the static
MetricsUtil.initializeProducerswhich results in an indirect call to
registerMetrics`?I was thinking about moving the static
initializeMetrics
out of MetricsUtil and put the functionality into AbstractServer - I think that functionality only applies to services extending AbstractServer.
I think that might be fine iff only AbstractServer subclasses call that method.
The
initializeProducers
functionality needs to exist to register metrics producers for things that are created outside of the AbstarctServer context (thrift metrics, cache,....) - but those are created / exist within a service context that has already been expected to initialize the registry.
agreed
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.
Addressed in 49b93b3 - backed of removal of MetricsUtil for now to minimize changes. May look into additional changes in future PRs, but this code works as expected.
I think with these changes overall, all subclasses of AbstractServer need to call MetricsUtil.initializeProducers, passing in |
Adds metric to detect low memory conditions