Avoid setting hostname tag on local root span if empty

This commit is contained in:
Luca Abbati 2019-05-17 21:55:02 +02:00
parent 429fb6772e
commit 3b8257a123
No known key found for this signature in database
GPG Key ID: C901DDA2FFE14529
1 changed files with 12 additions and 3 deletions

View File

@ -323,12 +323,21 @@ public class Config {
/** @return A map of tags to be applied only to the local application root span. */
public Map<String, String> getLocalRootSpanTags() {
final Map<String, String> runtimeTags = getRuntimeTags();
final Map<String, String> result =
newHashMap(reportHostName ? (runtimeTags.size() + 1) : runtimeTags.size());
result.putAll(runtimeTags);
String hostname = "";
if (reportHostName) {
hostname = getHostname();
}
boolean shouldReportHostName = null != hostname && !hostname.isEmpty();
final Map<String, String> result =
newHashMap(shouldReportHostName ? (runtimeTags.size() + 1) : runtimeTags.size());
result.putAll(runtimeTags);
if (shouldReportHostName) {
result.put(INTERNAL_HOST_NAME, getHostname());
}
return Collections.unmodifiableMap(result);
}