From 3d8012fc56c0d80a1df3daa8c8d3b6be6cc5e50d Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 9 Mar 2021 08:50:21 +0100 Subject: [PATCH] Parameterized the path key (OTel uses http.route) --- .../client/integration/sampled/WebClientTests.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/common/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/integration/sampled/WebClientTests.java b/tests/common/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/integration/sampled/WebClientTests.java index 68b15e85e..bebe8d0fd 100644 --- a/tests/common/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/integration/sampled/WebClientTests.java +++ b/tests/common/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/integration/sampled/WebClientTests.java @@ -146,18 +146,21 @@ public abstract class WebClientTests { then(this.spans).isNotEmpty(); Optional noTraceSpan = this.spans.reportedSpans().stream() .filter(span -> span.getName().contains("GET") && !span.getTags().isEmpty() - && span.getTags().containsKey("http.path")) + && span.getTags().containsKey(pathKey())) .findFirst(); then(noTraceSpan.isPresent()).isTrue(); - then(noTraceSpan.get().getTags()).containsEntry("http.path", "/notrace").containsEntry("http.method", - "GET"); + then(noTraceSpan.get().getTags()).containsEntry(pathKey(), "/notrace").containsEntry("http.method", "GET"); // TODO: matches cause there is an issue with Feign not providing the full URL // at the interceptor level - then(noTraceSpan.get().getTags().get("http.path")).matches(".*/notrace"); + then(noTraceSpan.get().getTags().get(pathKey())).matches(".*/notrace"); }); thenThereIsNoCurrentSpan(); } + protected String pathKey() { + return "http.path"; + } + private void thenThereIsNoCurrentSpan() { log.info("Current span [" + this.tracer.currentSpan() + "]"); then(this.tracer.currentSpan()).isNull();