@@ -323,12 +323,15 @@ private Config(final Properties properties, final Config parent) {
323323 /** @return A map of tags to be applied only to the local application root span. */
324324 public Map <String , String > getLocalRootSpanTags () {
325325 final Map <String , String > runtimeTags = getRuntimeTags ();
326- final Map <String , String > result =
327- newHashMap (reportHostName ? (runtimeTags .size () + 1 ) : runtimeTags .size ());
328- result .putAll (runtimeTags );
326+ final Map <String , String > result = new HashMap <>(runtimeTags );
327+
329328 if (reportHostName ) {
330- result .put (INTERNAL_HOST_NAME , getHostname ());
329+ String hostName = getHostName ();
330+ if (null != hostName && !hostName .isEmpty ()) {
331+ result .put (INTERNAL_HOST_NAME , hostName );
332+ }
331333 }
334+
332335 return Collections .unmodifiableMap (result );
333336 }
334337
@@ -668,7 +671,7 @@ private static <V extends Enum<V>> Set<V> convertStringSetToEnumSet(
668671 * Returns the detected hostname. This operation is time consuming so if the usage changes and
669672 * this method will be called several times then we should implement some sort of caching.
670673 */
671- private String getHostname () {
674+ private String getHostName () {
672675 try {
673676 return InetAddress .getLocalHost ().getHostName ();
674677 } catch (UnknownHostException e ) {
0 commit comments