File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed
dd-trace-core/src/main/java/datadog/trace/core/tagprocessor
internal-api/src/main/java/datadog/trace/api Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 11package datadog .trace .core .tagprocessor ;
22
3- import datadog .trace .api .Config ;
43import datadog .trace .api .DDTags ;
54import datadog .trace .core .DDSpanContext ;
65import java .util .Map ;
6+ import java .util .function .Supplier ;
77
88public class RemoteHostnameAdder implements TagsPostProcessor {
9- private final Config config ;
9+ private final Supplier < String > hostnameSupplier ;
1010
11- public RemoteHostnameAdder (Config config ) {
12- this .config = config ;
11+ public RemoteHostnameAdder (Supplier < String > hostnameSupplier ) {
12+ this .hostnameSupplier = hostnameSupplier ;
1313 }
1414
1515 @ Override
1616 public Map <String , Object > processTags (
1717 Map <String , Object > unsafeTags , DDSpanContext spanContext ) {
1818 if (spanContext .getSpanId () == spanContext .getRootSpanId ()) {
19- unsafeTags .put (DDTags .TRACER_HOST , config . getHostName ());
19+ unsafeTags .put (DDTags .TRACER_HOST , hostnameSupplier . get ());
2020 }
2121 return unsafeTags ;
2222 }
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ private static TagsPostProcessor create() {
1717 }
1818 processors .add (new QueryObfuscator (Config .get ().getObfuscationQueryRegexp ()));
1919 if (addRemoteHostname ) {
20- processors .add (new RemoteHostnameAdder (Config .get ()));
20+ processors .add (new RemoteHostnameAdder (Config .get (). getHostNameSupplier () ));
2121 }
2222 return new PostProcessorChain (
2323 processors .toArray (processors .toArray (new TagsPostProcessor [0 ])));
Original file line number Diff line number Diff line change 540540import java .util .UUID ;
541541import java .util .concurrent .TimeUnit ;
542542import java .util .function .Function ;
543+ import java .util .function .Supplier ;
543544import java .util .regex .Matcher ;
544545import java .util .regex .Pattern ;
545546import javax .annotation .Nonnull ;
@@ -585,6 +586,10 @@ static class RuntimeIdHolder {
585586
586587 static class HostNameHolder {
587588 static final String hostName = initHostName ();
589+
590+ public static String getHostName () {
591+ return hostName ;
592+ }
588593 }
589594
590595 private final boolean runtimeIdEnabled ;
@@ -2272,6 +2277,10 @@ public String getHostName() {
22722277 return HostNameHolder .hostName ;
22732278 }
22742279
2280+ public Supplier <String > getHostNameSupplier () {
2281+ return HostNameHolder ::getHostName ;
2282+ }
2283+
22752284 public String getServiceName () {
22762285 return serviceName ;
22772286 }
You can’t perform that action at this time.
0 commit comments