Skip to content

Commit 2fcef61

Browse files
authored
Avoid direct casting of base service tag to string (#9489)
1 parent 6e135e5 commit 2fcef61

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

dd-trace-core/src/main/java/datadog/trace/common/metrics/ConflatingMetricsAggregator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,14 @@ private List<UTF8BytesString> getPeerTags(CoreSpan<?> span, String spanKind) {
367367
return peerTags;
368368
} else if (SPAN_KIND_INTERNAL.equals(spanKind)) {
369369
// in this case only the base service should be aggregated if present
370-
final String baseService = span.getTag(BASE_SERVICE);
370+
final Object baseService = span.getTag(BASE_SERVICE);
371371
if (baseService != null) {
372372
final Pair<DDCache<String, UTF8BytesString>, Function<String, UTF8BytesString>>
373373
cacheAndCreator = PEER_TAGS_CACHE.computeIfAbsent(BASE_SERVICE, PEER_TAGS_CACHE_ADDER);
374374
return Collections.singletonList(
375-
cacheAndCreator.getLeft().computeIfAbsent(baseService, cacheAndCreator.getRight()));
375+
cacheAndCreator
376+
.getLeft()
377+
.computeIfAbsent(baseService.toString(), cacheAndCreator.getRight()));
376378
}
377379
}
378380
return Collections.emptyList();

dd-trace-core/src/test/groovy/datadog/trace/common/metrics/ConflatingMetricAggregatorTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ class ConflatingMetricAggregatorTest extends DDSpecification {
263263
CountDownLatch latch = new CountDownLatch(1)
264264
aggregator.publish([
265265
new SimpleSpan("service", "operation", "resource", "type", true, false, false, 0, 100, HTTP_OK)
266-
.setTag(SPAN_KIND, kind).setTag("peer.hostname", "localhost").setTag("_dd.base_service", "test")
266+
.setTag(SPAN_KIND, kind).setTag("peer.hostname", "localhost").setTag("_dd.base_service", UTF8BytesString.create("test"))
267267
])
268268
aggregator.report()
269269
def latchTriggered = latch.await(2, SECONDS)

0 commit comments

Comments
 (0)