Skip to content

Commit d7e270f

Browse files
committed
Fix service name overrides in consumers
1 parent dcf73eb commit d7e270f

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

dd-trace-core/src/main/java/datadog/trace/core/datastreams/DataStreamContextExtractor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ public class DataStreamContextExtractor implements HttpCodec.Extractor {
1212
private final TimeSource timeSource;
1313
private final Supplier<TraceConfig> traceConfigSupplier;
1414
private final long hashOfKnownTags;
15-
private final String serviceNameOverride;
15+
private final ThreadLocal<String> serviceNameOverride;
1616

1717
public DataStreamContextExtractor(
1818
HttpCodec.Extractor delegate,
1919
TimeSource timeSource,
2020
Supplier<TraceConfig> traceConfigSupplier,
2121
long hashOfKnownTags,
22-
String serviceNameOverride) {
22+
ThreadLocal<String> serviceNameOverride) {
2323
this.delegate = delegate;
2424
this.timeSource = timeSource;
2525
this.traceConfigSupplier = traceConfigSupplier;
@@ -41,7 +41,7 @@ public <C> TagContext extract(C carrier, AgentPropagation.ContextVisitor<C> gett
4141
if (shouldExtractPathwayContext) {
4242
DefaultPathwayContext pathwayContext =
4343
DefaultPathwayContext.extract(
44-
carrier, getter, this.timeSource, this.hashOfKnownTags, serviceNameOverride);
44+
carrier, getter, this.timeSource, this.hashOfKnownTags, serviceNameOverride.get());
4545

4646
extracted.withPathwayContext(pathwayContext);
4747
}
@@ -50,7 +50,7 @@ public <C> TagContext extract(C carrier, AgentPropagation.ContextVisitor<C> gett
5050
} else if (traceConfigSupplier.get().isDataStreamsEnabled()) {
5151
DefaultPathwayContext pathwayContext =
5252
DefaultPathwayContext.extract(
53-
carrier, getter, this.timeSource, this.hashOfKnownTags, serviceNameOverride);
53+
carrier, getter, this.timeSource, this.hashOfKnownTags, serviceNameOverride.get());
5454

5555
if (pathwayContext != null) {
5656
extracted = new TagContext();

dd-trace-core/src/main/java/datadog/trace/core/datastreams/DataStreamPropagator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ public class DataStreamPropagator implements Propagator {
2020
private final Supplier<TraceConfig> traceConfigSupplier;
2121
private final TimeSource timeSource;
2222
private final long hashOfKnownTags;
23-
private final String serviceNameOverride;
23+
private final ThreadLocal<String> serviceNameOverride;
2424

2525
public DataStreamPropagator(
2626
Supplier<TraceConfig> traceConfigSupplier,
2727
TimeSource timeSource,
2828
long hashOfKnownTags,
29-
String serviceNameOverride) {
29+
ThreadLocal<String> serviceNameOverride) {
3030
this.traceConfigSupplier = traceConfigSupplier;
3131
this.timeSource = timeSource;
3232
this.hashOfKnownTags = hashOfKnownTags;
@@ -78,6 +78,6 @@ private boolean isDsmEnabled(@Nullable TagContext tagContext) {
7878

7979
private <C> PathwayContext extractDsmPathwayContext(C carrier, CarrierVisitor<C> visitor) {
8080
return DefaultPathwayContext.extract(
81-
carrier, visitor, this.timeSource, this.hashOfKnownTags, this.serviceNameOverride);
81+
carrier, visitor, this.timeSource, this.hashOfKnownTags, serviceNameOverride.get());
8282
}
8383
}

dd-trace-core/src/main/java/datadog/trace/core/datastreams/DefaultDataStreamsMonitoring.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ public PathwayContext newPathwayContext() {
204204
@Override
205205
public Propagator propagator() {
206206
return new DataStreamPropagator(
207-
this.traceConfigSupplier, this.timeSource, this.hashOfKnownTags, getThreadServiceName());
207+
this.traceConfigSupplier, this.timeSource, this.hashOfKnownTags, serviceNameOverride);
208208
}
209209

210210
@Override
211211
public HttpCodec.Extractor extractor(HttpCodec.Extractor delegate) {
212212
return new DataStreamContextExtractor(
213-
delegate, timeSource, traceConfigSupplier, hashOfKnownTags, getThreadServiceName());
213+
delegate, timeSource, traceConfigSupplier, hashOfKnownTags, serviceNameOverride);
214214
}
215215

216216
@Override

0 commit comments

Comments
 (0)