diff options
author | Rafael Chacon <rchacon@myfitnesspal.com> | 2014-08-26 10:09:22 -0700 |
---|---|---|
committer | Rafael Chacon <rchacon@myfitnesspal.com> | 2014-08-26 10:09:22 -0700 |
commit | 9d13ae86dab7f147d95131e84a56b037ae06f118 (patch) | |
tree | e9a0c8ec19f1ec7c3843384ddbf6976e516e82a1 /kamon-statsd/src/main/scala/kamon | |
parent | be65d54a8c120343f87f07f617b296bfc5442625 (diff) | |
download | Kamon-9d13ae86dab7f147d95131e84a56b037ae06f118.tar.gz Kamon-9d13ae86dab7f147d95131e84a56b037ae06f118.tar.bz2 Kamon-9d13ae86dab7f147d95131e84a56b037ae06f118.zip |
+ statsd: add hostname-override to statsd config options.
* This setting allows users to override the hostname used by
Kamon when sending metrics to statsd.
Diffstat (limited to 'kamon-statsd/src/main/scala/kamon')
-rw-r--r-- | kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala b/kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala index 76ef8d5f..a8d8ae48 100644 --- a/kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala +++ b/kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala @@ -107,6 +107,9 @@ class SimpleMetricKeyGenerator(config: Config) extends StatsD.MetricKeyGenerator val application = config.getString("kamon.statsd.simple-metric-key-generator.application") val includeHostnameInMetrics = config.getBoolean("kamon.statsd.simple-metric-key-generator.include-hostname") + val hostnameOverride = + config.getString("kamon.statsd.simple-metric-key-generator.hostname-override") + val _localhostName = ManagementFactory.getRuntimeMXBean.getName.split('@')(1) val _normalizedLocalhostName = _localhostName.replace('.', '_') @@ -114,8 +117,12 @@ class SimpleMetricKeyGenerator(config: Config) extends StatsD.MetricKeyGenerator def normalizedLocalhostName: String = _normalizedLocalhostName + val hostname: String = + if (hostnameOverride == "none") normalizedLocalhostName + else hostnameOverride + val baseName: String = - if (includeHostnameInMetrics) s"${application}.${normalizedLocalhostName}" + if (includeHostnameInMetrics) s"${application}.${hostname}" else application def generateKey(groupIdentity: MetricGroupIdentity, metricIdentity: MetricIdentity): String = { |