Add support for prefixing the metrics with a CLI supplied option
Fixes #15
This commit is contained in:
parent
95c244867a
commit
0fa983d0e8
|
@ -7,7 +7,7 @@ apply plugin: 'application'
|
||||||
|
|
||||||
group = "com.github.lookout"
|
group = "com.github.lookout"
|
||||||
description = "A utility for monitoring the delay of Kafka consumers"
|
description = "A utility for monitoring the delay of Kafka consumers"
|
||||||
version = '0.1.4'
|
version = '0.1.5'
|
||||||
mainClassName = 'com.github.lookout.verspaetung.Main'
|
mainClassName = 'com.github.lookout.verspaetung.Main'
|
||||||
defaultTasks 'clean', 'check'
|
defaultTasks 'clean', 'check'
|
||||||
sourceCompatibility = '1.7'
|
sourceCompatibility = '1.7'
|
||||||
|
|
|
@ -26,6 +26,7 @@ class Main {
|
||||||
private static Logger logger
|
private static Logger logger
|
||||||
|
|
||||||
static void main(String[] args) {
|
static void main(String[] args) {
|
||||||
|
String statsdPrefix = METRICS_PREFIX
|
||||||
String zookeeperHosts = 'localhost:2181'
|
String zookeeperHosts = 'localhost:2181'
|
||||||
String statsdHost = 'localhost'
|
String statsdHost = 'localhost'
|
||||||
Integer statsdPort = 8125
|
Integer statsdPort = 8125
|
||||||
|
@ -48,11 +49,15 @@ class Main {
|
||||||
logger.info("Running with: ${args}")
|
logger.info("Running with: ${args}")
|
||||||
logger.warn("Using: zookeepers=${zookeeperHosts} statsd=${statsdHost}:${statsdPort}")
|
logger.warn("Using: zookeepers=${zookeeperHosts} statsd=${statsdHost}:${statsdPort}")
|
||||||
|
|
||||||
|
if (cli.hasOption('prefix')) {
|
||||||
|
statsdPrefix = "${cli.getOptionValue('prefix')}.${METRICS_PREFIX}"
|
||||||
|
}
|
||||||
|
|
||||||
ExponentialBackoffRetry retry = new ExponentialBackoffRetry(1000, 3)
|
ExponentialBackoffRetry retry = new ExponentialBackoffRetry(1000, 3)
|
||||||
CuratorFramework client = CuratorFrameworkFactory.newClient(zookeeperHosts, retry)
|
CuratorFramework client = CuratorFrameworkFactory.newClient(zookeeperHosts, retry)
|
||||||
ConcurrentHashMap<TopicPartition, List<zk.ConsumerOffset>> consumers = new ConcurrentHashMap()
|
ConcurrentHashMap<TopicPartition, List<zk.ConsumerOffset>> consumers = new ConcurrentHashMap()
|
||||||
|
|
||||||
statsd = new NonBlockingDogStatsDClient(METRICS_PREFIX, statsdHost, statsdPort)
|
statsd = new NonBlockingDogStatsDClient(statsdPrefix, statsdHost, statsdPort)
|
||||||
|
|
||||||
client.start()
|
client.start()
|
||||||
|
|
||||||
|
@ -148,9 +153,17 @@ class Main {
|
||||||
.withLongOpt('storm')
|
.withLongOpt('storm')
|
||||||
.create('s')
|
.create('s')
|
||||||
|
|
||||||
|
Option statsdPrefix = OptionBuilder.withArgName('PREFIX')
|
||||||
|
.hasArg()
|
||||||
|
.withType(String)
|
||||||
|
.withDescription("Prefix all metrics with PREFIX before they're reported (e.g. PREFIX.verspaetung.mytopic)")
|
||||||
|
.withLongOpt('prefix')
|
||||||
|
.create()
|
||||||
|
|
||||||
options.addOption(zookeeper)
|
options.addOption(zookeeper)
|
||||||
options.addOption(statsdHost)
|
options.addOption(statsdHost)
|
||||||
options.addOption(statsdPort)
|
options.addOption(statsdPort)
|
||||||
|
options.addOption(statsdPrefix)
|
||||||
options.addOption(dryRun)
|
options.addOption(dryRun)
|
||||||
options.addOption(stormSpouts)
|
options.addOption(stormSpouts)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue