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

Changing to use spectator for metrics #118

Merged
merged 3 commits into from
May 19, 2017
Merged

Conversation

zhljen
Copy link
Contributor

@zhljen zhljen commented May 19, 2017

No description provided.

@zhljen zhljen added this to the 1.1.0 milestone May 19, 2017
@@ -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
Copy link
Contributor

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();
Copy link
Contributor

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

Copy link
Contributor Author

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();
Copy link
Contributor

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

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 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"),
Copy link
Contributor

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.

Copy link
Contributor Author

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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"),
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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"),
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

keep reference to timer

Copy link
Contributor Author

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);
Copy link
Contributor

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

Copy link
Contributor

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.

@tgianos tgianos merged commit 32a6ee4 into Netflix:master May 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants