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
JIRA: SAMZA-1733 Specify MetricsSnapshotStream partitionKey in config #542
Conversation
rayman7718
commented
May 31, 2018
- Adding config to specify MetricsSnapshotStream partitionKey, defaults to hostname (to maintain backword compat)
… to hostname (to maintain backword compat)
* @param systemStream The systemStream for the MetricsSnapshotStream | ||
* @return the metric key name (if specified), else None | ||
*/ | ||
def getMetricsReporterStreamPartitionKeyName(systemStream: SystemStream): Option[String] = getOption(MetricsConfig.METRICS_SNAPSHOT_REPORTER_PARTITION_KEY format(systemStream.getSystem, systemStream.getStream)) |
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.
Should expose these configs independent of the systemStream
. One alternative:
reporters.snapshot.key whose values can be in the set: {host, jobId, jobName}
…an by systemStream
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.
another pass with suggestions for code organization. please let me know if something is unclear.
val METRICS_SNAPSHOT_REPORTER_INTERVAL = "metrics.reporter.%s.interval" | ||
val METRICS_TIMER_ENABLED = "metrics.timer.enabled" | ||
val METRICS_SNAPSHOT_REPORTER_PARTITION_KEY = "metrics.reporter.%s.partitionkey" | ||
val METRICS_SNAPSHOT_REPORTER_PARTITION_KEY_JOBNAME = "jobname" |
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.
s/partition_key_jobname/partition_key_default
* @param jobName the current job name | ||
* @param hostname the current host name | ||
*/ | ||
def getMetricsReporterStreamPartitionKeyValue(keyName: Option[String], jobName: String, hostname: String) = keyName match { |
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.
prefer moving this method out of the MetricReporterConfig and instead adding it to SnapshotReporter
instead.
…moving getPartitionValue method to MetricsSnapshotReporter
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.
Mostly lgtm. Just some minor comments on coding style/pattern. Thanks!
val METRICS_TIMER_ENABLED= "metrics.timer.enabled" | ||
val METRICS_SNAPSHOT_REPORTER_INTERVAL = "metrics.reporter.%s.interval" | ||
val METRICS_TIMER_ENABLED = "metrics.timer.enabled" | ||
val METRICS_SNAPSHOT_REPORTER_PARTITION_KEY = "metrics.reporter.%s.partitionkey" |
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.
Just curious, shouldn't we have a default value for this configuration variable?
import java.util.HashMap | ||
import java.util.Map | ||
import java.util.concurrent.Executors | ||
import java.util.concurrent.TimeUnit | ||
|
||
import scala.collection.JavaConverters._ | ||
|
||
object MetricsSnapshotReporter { | ||
val METRICS_SNAPSHOT_REPORTER_PARTITION_KEY_DEFAULT = "jobname" |
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 use a pattern where the default value is set in config class's getXXXConfig() methods, instead of the static defaults in the implementation class.
def getMetricsReporterStreamPartitionKeyValue(keyName: String, jobName: String, hostname: String) = keyName match { | ||
case "jobname" => jobName | ||
case "hostname" => hostname | ||
case _ => keyName |
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 this keyName or keyValue? The javadoc says "else returns the actual value specified", but the input argument only have key name. In addition, if "jobname" and "hostname" are special key names, I would prefer to define those as constant in MetricsConfig.