com.signalfx.metrics.SourceNameHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signalfx-codahale Show documentation
Show all versions of signalfx-codahale Show documentation
Dropwizard Codahale metrics plugin for signalfx
The newest version!
package com.signalfx.metrics;
import java.net.InetAddress;
import java.net.UnknownHostException;
public final class SourceNameHelper {
private SourceNameHelper() {
}
public static String getDefaultSourceName() {
String sourceName = System.getProperty("com.signalfx.sourceName");
if (sourceName != null && !sourceName.isEmpty()) {
return sourceName;
}
sourceName = System.getenv("SIGNALFX_SOURCE_NAME");
if (sourceName != null && !sourceName.isEmpty()) {
return sourceName;
}
try {
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
}
sourceName = System.getenv("COMPUTERNAME");
if (sourceName != null && !sourceName.isEmpty()) {
return sourceName;
}
sourceName = System.getenv("HOSTNAME");
if (sourceName != null && !sourceName.isEmpty()) {
return sourceName;
}
throw new RuntimeException(
"Unable to find a default source name. Please set one with usingDefaultSource()");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy