-
Notifications
You must be signed in to change notification settings - Fork 277
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
Changing to use spectator for metrics #118
Conversation
gradle.properties
Outdated
@@ -37,4 +37,5 @@ hive_version=1.2.1 | |||
|
|||
## speed up the build process | |||
#org.gradle.parallel=true | |||
org.gradle.jvmargs=-Xmx2G | |||
org.gradle.jvmargs=-Xmx4G |
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.
Cant we pass this as command arguments?
@@ -60,7 +65,7 @@ public MetacatEventBus( | |||
*/ | |||
public void postAsync(final ApplicationEvent event) { | |||
log.debug("Received request to post an event {} asynchronously", event); | |||
CounterWrapper.incrementCounter("metacat.events.async"); | |||
registry.counter(LogConstants.CounterEventAsync.name()).increment(); |
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.
Shouldn't it be called MetricConstants
not LogConstants
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.
Agreed.
@@ -71,7 +76,7 @@ public void postAsync(final ApplicationEvent event) { | |||
*/ | |||
public void postSync(final ApplicationEvent event) { | |||
log.debug("Received request to post an event {} synchronously", event); | |||
CounterWrapper.incrementCounter("metacat.events.sync"); | |||
registry.counter(LogConstants.CounterEventSync.name()).increment(); |
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.
Is it better to do this than to just have a counter reference saved in the constructor as a private member so we don't have to get the name every time? Then we just call increment on the local reference
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.
The spectator itself has the counter reference cached. The counter only works in active mode and introducing a local id variable will not save. The gauge is the only one that has passive mode, where caches the reference at application will be useful.
/** | ||
* evnets. | ||
*/ | ||
CounterEventAsync(AppPrefix + ".events.count.Async"), |
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 seems to me that Async vs. Sync could be a tag rather than part of the name.
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 it's ok to let them be a separated counter for consistency. There're other cases like this, e.g. tableCreate, tableDelete, etc. A couple of cased the tags used are (1) the status of operations, failure/succeed; (2) the catalog/database/table names in case of the same operation.
|
||
import java.util.Map; | ||
|
||
//CHECKSTYLE:OFF | ||
/** | ||
* Log constants. | ||
*/ | ||
public enum LogConstants { |
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.
Rename to MetricsConstants and why is it an enumeration instead of just a class of string constants?
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 can be defined as a constant class. But it also has methods, and needs to be a singleton. Enum seems ok. The naming is bit misleading, and should be renamed as Metrics
/** | ||
* Notifications. | ||
*/ | ||
CounterSNSNotificationPartitionAdd(AppPrefix + ".notifications.count.partitionsAdd"), |
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 might move count to the end. like partitionsAdd.count
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 for the consistency of naming, i.e. the component.spectatorType.measureName. The type can be count, gauge, timer.
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 we should flip it so it's component.measureName.type... I say this cause when we type it into the atlas search filter later on we can better filter down by the metrics and we'll then see that metric name will have a counter, gauge or timer associated with it as opposed to having to back out from the metric to see other metrics cause they're grouped under type... @ajoymajumdar opinion?
CounterElasticSearchDelete(AppPrefix + ".elasticsearch.count.esDelete"), | ||
CounterElasticSearchBulkDelete(AppPrefix + ".elasticsearch.count.esBulkDelete"), | ||
CounterElasticSearchUpdate(AppPrefix + ".elasticsearch.count.esUpdate"), | ||
CounterElasticSearchBulkUpdate(AppPrefix + ".elasticsearch.count.esBulkUpdate"), |
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.
isn't having it elasticsearch
and then es
prefix on the name itself kind of redundant?
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 to separated the operations from metacat e.g. database/table or elasticSearch itself. The elasticsearch prefix indicates the components, and the 'es' indicates the operation target.
DynamicGauge.set(metricNameActive, parent.getActive()); | ||
DynamicGauge.set(metricNameIdle, parent.getIdle()); | ||
if (parent != null | ||
&& metricNameTotalGauage != null |
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.
Rather than doing all these null checks why wouldn't you just instantiate the gauges once in the constructor and make them final member variables?
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.
We cannot since Tomcat pool implementation needs a default empty constructor.
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.
They can't be instantiated in the constructor, as the "metricName" are unknown at that time.
private IMetacatHiveClient createLocalClient() throws Exception { | ||
final HiveConf conf = getDefaultConf(); | ||
configuration.forEach(conf::set); | ||
//TO DO Change the usage of DataSourceManager later |
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.
really minor but you should make this TODO one word so we can find it quickly and IDE's will pick it up
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.
Agreed.
log.info("###### Time taken to complete " | ||
+ "HiveConnectorFastPartitionService.getPartitions is {} ms", timer.stop()); | ||
+ "HiveConnectorFastPartitionService.getPartitions is {} ms", duration); | ||
this.registry.timer(LogConstants.TimerHiveGetPartitions.name()).record(duration, TimeUnit.MILLISECONDS); |
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.
keep reference to timer
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.
Similar as the counter explanation.
final long duration = registry.clock().monotonicTime() - start; | ||
this.registry.timer(LogConstants.TimerThriftRequest.name() | ||
+ "." + methodName).record(duration, TimeUnit.MILLISECONDS); | ||
log.info("+++ Thrift({}): Time taken to complete {} is {} ms", catalogName, methodName, duration); |
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.
Do we really want all this to be info level? Seems to me they might be better as debug? Not sure how @ajoymajumdar has this overall
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.
Info is fine. All request methods log info messages at the start and end of the request.
No description provided.