Bumping versions
This commit is contained in:
@@ -40,8 +40,7 @@ public class SampleFeignApplicationTests {
|
||||
|
||||
// https://github.com/spring-cloud/spring-cloud-sleuth/issues/1396
|
||||
@Test
|
||||
public void should_not_pass_dash_as_default_service_name(
|
||||
CapturedOutput outputCapture) {
|
||||
public void should_not_pass_dash_as_default_service_name(CapturedOutput outputCapture) {
|
||||
log.info("HELLO");
|
||||
|
||||
BDDAssertions.then(outputCapture.toString()).doesNotContain("INFO [-,,,]");
|
||||
|
||||
@@ -32,8 +32,7 @@ import org.springframework.web.client.RestTemplate;
|
||||
*
|
||||
*/
|
||||
@MessageEndpoint
|
||||
public class SampleService
|
||||
implements ApplicationListener<ServletWebServerInitializedEvent> {
|
||||
public class SampleService implements ApplicationListener<ServletWebServerInitializedEvent> {
|
||||
|
||||
private static final Log log = LogFactory.getLog(SampleService.class);
|
||||
|
||||
@@ -45,8 +44,7 @@ public class SampleService
|
||||
@ServiceActivator(inputChannel = "messages")
|
||||
public void log(Message<?> message) {
|
||||
log.info("Received: " + message);
|
||||
this.restTemplate.getForObject("http://localhost:" + this.port + "/foo",
|
||||
String.class);
|
||||
this.restTemplate.getForObject("http://localhost:" + this.port + "/foo", String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,8 +32,7 @@ import org.apache.commons.logging.Log;
|
||||
*/
|
||||
public class IntegrationTestZipkinSpanHandler extends SpanHandler {
|
||||
|
||||
private static final Log log = org.apache.commons.logging.LogFactory
|
||||
.getLog(IntegrationTestZipkinSpanHandler.class);
|
||||
private static final Log log = org.apache.commons.logging.LogFactory.getLog(IntegrationTestZipkinSpanHandler.class);
|
||||
|
||||
public List<MutableSpan> spans = Collections.synchronizedList(new LinkedList<>());
|
||||
|
||||
|
||||
@@ -42,9 +42,7 @@ import org.springframework.test.context.TestPropertySource;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
@SpringBootTest(
|
||||
classes = { IntegrationSpanCollectorConfig.class,
|
||||
SampleMessagingApplication.class },
|
||||
@SpringBootTest(classes = { IntegrationSpanCollectorConfig.class, SampleMessagingApplication.class },
|
||||
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
||||
@TestPropertySource(properties = { "sample.zipkin.enabled=true" })
|
||||
@DirtiesContext
|
||||
@@ -66,12 +64,10 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
|
||||
public void should_have_passed_trace_id_when_message_is_about_to_be_sent() {
|
||||
long traceId = new Random().nextLong();
|
||||
|
||||
await().atMost(15, SECONDS)
|
||||
.untilAsserted(() -> httpMessageWithTraceIdInHeadersIsSuccessfullySent(
|
||||
sampleAppUrl + "/", traceId).run());
|
||||
await().atMost(15, SECONDS).untilAsserted(
|
||||
() -> httpMessageWithTraceIdInHeadersIsSuccessfullySent(sampleAppUrl + "/", traceId).run());
|
||||
|
||||
await().atMost(15, SECONDS)
|
||||
.untilAsserted(() -> thenAllSpansHaveTraceIdEqualTo(traceId));
|
||||
await().atMost(15, SECONDS).untilAsserted(() -> thenAllSpansHaveTraceIdEqualTo(traceId));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,9 +75,8 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
|
||||
long traceId = new Random().nextLong();
|
||||
long spanId = new Random().nextLong();
|
||||
|
||||
await().atMost(15, SECONDS)
|
||||
.untilAsserted(() -> httpMessageWithTraceIdInHeadersIsSuccessfullySent(
|
||||
sampleAppUrl + "/", traceId, spanId).run());
|
||||
await().atMost(15, SECONDS).untilAsserted(
|
||||
() -> httpMessageWithTraceIdInHeadersIsSuccessfullySent(sampleAppUrl + "/", traceId, spanId).run());
|
||||
|
||||
await().atMost(15, SECONDS).untilAsserted(() -> {
|
||||
thenAllSpansHaveTraceIdEqualTo(traceId);
|
||||
@@ -93,9 +88,8 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
|
||||
public void should_have_passed_trace_id_with_annotations_in_async_thread_when_message_is_about_to_be_sent() {
|
||||
long traceId = new Random().nextLong();
|
||||
|
||||
await().atMost(15, SECONDS)
|
||||
.untilAsserted(() -> httpMessageWithTraceIdInHeadersIsSuccessfullySent(
|
||||
sampleAppUrl + "/xform", traceId).run());
|
||||
await().atMost(15, SECONDS).untilAsserted(
|
||||
() -> httpMessageWithTraceIdInHeadersIsSuccessfullySent(sampleAppUrl + "/xform", traceId).run());
|
||||
|
||||
await().atMost(15, SECONDS).untilAsserted(() -> {
|
||||
thenAllSpansHaveTraceIdEqualTo(traceId);
|
||||
@@ -104,18 +98,17 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
|
||||
}
|
||||
|
||||
private void thenThereIsAtLeastOneTagWithKey(String key) {
|
||||
then(this.testSpanHandler.spans.stream().map(MutableSpan::tags)
|
||||
.flatMap(m -> m.keySet().stream()).anyMatch(b -> b.equals(key))).isTrue();
|
||||
then(this.testSpanHandler.spans.stream().map(MutableSpan::tags).flatMap(m -> m.keySet().stream())
|
||||
.anyMatch(b -> b.equals(key))).isTrue();
|
||||
}
|
||||
|
||||
private void thenAllSpansHaveTraceIdEqualTo(long traceId) {
|
||||
String traceIdHex = Long.toHexString(traceId);
|
||||
log.info("Stored spans: [\n" + this.testSpanHandler.spans.stream()
|
||||
.map(MutableSpan::toString).collect(Collectors.joining("\n")) + "\n]");
|
||||
then(this.testSpanHandler.spans.stream()
|
||||
.filter(span -> !span.traceId().equals(SpanUtil.idToHex(traceId)))
|
||||
.collect(Collectors.toList()))
|
||||
.describedAs("All spans have same trace id [" + traceIdHex + "]")
|
||||
log.info("Stored spans: [\n"
|
||||
+ this.testSpanHandler.spans.stream().map(MutableSpan::toString).collect(Collectors.joining("\n"))
|
||||
+ "\n]");
|
||||
then(this.testSpanHandler.spans.stream().filter(span -> !span.traceId().equals(SpanUtil.idToHex(traceId)))
|
||||
.collect(Collectors.toList())).describedAs("All spans have same trace id [" + traceIdHex + "]")
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@@ -127,13 +120,11 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
|
||||
Optional<MutableSpan> lastHttpSpansParent = findLastHttpSpansParent();
|
||||
// "http:/parent/" -> "message:messages" -> "http:/foo" (CS + CR) -> "http:/foo"
|
||||
// (SS)
|
||||
thenAllSpansArePresent(firstHttpSpan, eventSpans, lastHttpSpansParent,
|
||||
eventSentSpan, producerSpan);
|
||||
thenAllSpansArePresent(firstHttpSpan, eventSpans, lastHttpSpansParent, eventSentSpan, producerSpan);
|
||||
then(this.testSpanHandler.spans).as("There were 6 spans").hasSize(6);
|
||||
log.info("Checking the parent child structure");
|
||||
List<Optional<MutableSpan>> parentChild = this.testSpanHandler.spans.stream()
|
||||
.filter(span -> span.parentId() != null)
|
||||
.map(span -> this.testSpanHandler.spans.stream()
|
||||
.filter(span -> span.parentId() != null).map(span -> this.testSpanHandler.spans.stream()
|
||||
.filter(span1 -> span1.id().equals(span.parentId())).findAny())
|
||||
.collect(Collectors.toList());
|
||||
log.info("List of parents and children " + parentChild);
|
||||
@@ -141,32 +132,27 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
|
||||
}
|
||||
|
||||
private Optional<MutableSpan> findLastHttpSpansParent() {
|
||||
return this.testSpanHandler.spans.stream()
|
||||
.filter(span -> "GET /".equals(span.name()) && span.kind() != null)
|
||||
return this.testSpanHandler.spans.stream().filter(span -> "GET /".equals(span.name()) && span.kind() != null)
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
private Optional<MutableSpan> findSpanWithKind(Span.Kind kind) {
|
||||
return this.testSpanHandler.spans.stream()
|
||||
.filter(span -> kind.equals(span.kind())).findFirst();
|
||||
return this.testSpanHandler.spans.stream().filter(span -> kind.equals(span.kind())).findFirst();
|
||||
}
|
||||
|
||||
private List<MutableSpan> findAllEventRelatedSpans() {
|
||||
return this.testSpanHandler.spans.stream()
|
||||
.filter(span -> "send".equals(span.name()) && span.parentId() != null)
|
||||
return this.testSpanHandler.spans.stream().filter(span -> "send".equals(span.name()) && span.parentId() != null)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Optional<MutableSpan> findFirstHttpRequestSpan() {
|
||||
return this.testSpanHandler.spans.stream()
|
||||
// home is the name of the method
|
||||
.filter(span -> span.tags().values().stream().anyMatch("home"::equals))
|
||||
.findFirst();
|
||||
.filter(span -> span.tags().values().stream().anyMatch("home"::equals)).findFirst();
|
||||
}
|
||||
|
||||
private void thenAllSpansArePresent(Optional<MutableSpan> firstHttpSpan,
|
||||
List<MutableSpan> eventSpans, Optional<MutableSpan> lastHttpSpan,
|
||||
Optional<MutableSpan> eventSentSpan,
|
||||
private void thenAllSpansArePresent(Optional<MutableSpan> firstHttpSpan, List<MutableSpan> eventSpans,
|
||||
Optional<MutableSpan> lastHttpSpan, Optional<MutableSpan> eventSentSpan,
|
||||
Optional<MutableSpan> eventReceivedSpan) {
|
||||
log.info("Found following spans");
|
||||
log.info("First http span " + firstHttpSpan);
|
||||
@@ -174,8 +160,8 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
|
||||
log.info("Event sent span " + eventSentSpan);
|
||||
log.info("Event received span " + eventReceivedSpan);
|
||||
log.info("Last http span " + lastHttpSpan);
|
||||
log.info("All found spans \n" + this.testSpanHandler.spans.stream()
|
||||
.map(MutableSpan::toString).collect(Collectors.joining("\n")));
|
||||
log.info("All found spans \n"
|
||||
+ this.testSpanHandler.spans.stream().map(MutableSpan::toString).collect(Collectors.joining("\n")));
|
||||
then(firstHttpSpan.isPresent()).isTrue();
|
||||
then(eventSpans).isNotEmpty();
|
||||
then(eventSentSpan.isPresent()).isTrue();
|
||||
|
||||
@@ -39,17 +39,14 @@ public abstract class AbstractIntegrationTest {
|
||||
protected final RestTemplate restTemplate = new AssertingRestTemplate();
|
||||
|
||||
public static ConditionFactory await() {
|
||||
return Awaitility.await().pollInterval(POLL_INTERVAL, SECONDS).atMost(TIMEOUT,
|
||||
SECONDS);
|
||||
return Awaitility.await().pollInterval(POLL_INTERVAL, SECONDS).atMost(TIMEOUT, SECONDS);
|
||||
}
|
||||
|
||||
protected Runnable httpMessageWithTraceIdInHeadersIsSuccessfullySent(String endpoint,
|
||||
long traceId) {
|
||||
protected Runnable httpMessageWithTraceIdInHeadersIsSuccessfullySent(String endpoint, long traceId) {
|
||||
return new RequestSendingRunnable(this.restTemplate, endpoint, traceId, traceId);
|
||||
}
|
||||
|
||||
protected Runnable httpMessageWithTraceIdInHeadersIsSuccessfullySent(String endpoint,
|
||||
long traceId, Long spanId) {
|
||||
protected Runnable httpMessageWithTraceIdInHeadersIsSuccessfullySent(String endpoint, long traceId, Long spanId) {
|
||||
return new RequestSendingRunnable(this.restTemplate, endpoint, traceId, spanId);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ public class AssertingRestTemplate extends RestTemplate {
|
||||
@Override
|
||||
public void handleError(ClientHttpResponse response) throws IOException {
|
||||
if (hasError(response)) {
|
||||
log.error("Response has status code [" + response.getStatusCode()
|
||||
+ "] and text [" + response.getStatusText() + "])");
|
||||
log.error("Response has status code [" + response.getStatusCode() + "] and text ["
|
||||
+ response.getStatusText() + "])");
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -60,8 +60,8 @@ public class AssertingRestTemplate extends RestTemplate {
|
||||
return super.doExecute(url, method, requestCallback, responseExtractor);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Exception occurred while sending the message to uri [" + url
|
||||
+ "]. Exception [" + e.getCause() + "]");
|
||||
log.error("Exception occurred while sending the message to uri [" + url + "]. Exception [" + e.getCause()
|
||||
+ "]");
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +52,7 @@ public class RequestSendingRunnable implements Runnable {
|
||||
|
||||
private final long spanId;
|
||||
|
||||
public RequestSendingRunnable(RestTemplate restTemplate, String url, long traceId,
|
||||
Long spanId) {
|
||||
public RequestSendingRunnable(RestTemplate restTemplate, String url, long traceId, Long spanId) {
|
||||
this.restTemplate = restTemplate;
|
||||
this.url = url;
|
||||
this.traceId = traceId;
|
||||
@@ -62,11 +61,9 @@ public class RequestSendingRunnable implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
log.info(String.format(
|
||||
"Sending the request to url [%s] with trace id in headers [%d]", this.url,
|
||||
this.traceId));
|
||||
ResponseEntity<String> responseEntity = this.restTemplate
|
||||
.exchange(requestWithTraceId(), String.class);
|
||||
log.info(
|
||||
String.format("Sending the request to url [%s] with trace id in headers [%d]", this.url, this.traceId));
|
||||
ResponseEntity<String> responseEntity = this.restTemplate.exchange(requestWithTraceId(), String.class);
|
||||
then(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
log.info(String.format("Received the following response [%s]", responseEntity));
|
||||
}
|
||||
@@ -75,8 +72,7 @@ public class RequestSendingRunnable implements Runnable {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("b3", idToHex(this.traceId) + "-" + idToHex(this.spanId));
|
||||
URI uri = URI.create(this.url);
|
||||
RequestEntity<Void> requestEntity = new RequestEntity<>(headers, HttpMethod.GET,
|
||||
uri);
|
||||
RequestEntity<Void> requestEntity = new RequestEntity<>(headers, HttpMethod.GET, uri);
|
||||
log.info("Request [" + requestEntity + "] is ready");
|
||||
return requestEntity;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,7 @@ public final class SpanUtil {
|
||||
throw new IllegalStateException("Can't instantiate a utility class");
|
||||
}
|
||||
|
||||
static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'a', 'b', 'c', 'd', 'e', 'f' };
|
||||
static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
||||
|
||||
// Represents given long id as 16-character lower-hex string
|
||||
public static String idToHex(long id) {
|
||||
|
||||
@@ -35,8 +35,7 @@ import org.springframework.web.client.RestTemplate;
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@RestController
|
||||
public class SampleController
|
||||
implements ApplicationListener<ServletWebServerInitializedEvent> {
|
||||
public class SampleController implements ApplicationListener<ServletWebServerInitializedEvent> {
|
||||
|
||||
private static final Log log = LogFactory.getLog(SampleController.class);
|
||||
|
||||
@@ -57,8 +56,7 @@ public class SampleController
|
||||
public String hi() throws InterruptedException {
|
||||
Thread.sleep(this.random.nextInt(1000));
|
||||
log.info("Home page");
|
||||
String s = this.restTemplate
|
||||
.getForObject("http://localhost:" + this.port + "/hi2", String.class);
|
||||
String s = this.restTemplate.getForObject("http://localhost:" + this.port + "/hi2", String.class);
|
||||
return "hi/" + s;
|
||||
}
|
||||
|
||||
@@ -100,8 +98,7 @@ public class SampleController
|
||||
Thread.sleep(millis);
|
||||
this.tracer.currentSpan().tag("random-sleep-millis", String.valueOf(millis));
|
||||
|
||||
String s = this.restTemplate
|
||||
.getForObject("http://localhost:" + this.port + "/call", String.class);
|
||||
String s = this.restTemplate.getForObject("http://localhost:" + this.port + "/call", String.class);
|
||||
span.finish();
|
||||
return "traced/" + s;
|
||||
}
|
||||
@@ -112,8 +109,7 @@ public class SampleController
|
||||
log.info(String.format("Sleeping for [%d] millis", millis));
|
||||
Thread.sleep(millis);
|
||||
this.tracer.currentSpan().tag("random-sleep-millis", String.valueOf(millis));
|
||||
String s = this.restTemplate
|
||||
.getForObject("http://localhost:" + this.port + "/call", String.class);
|
||||
String s = this.restTemplate.getForObject("http://localhost:" + this.port + "/call", String.class);
|
||||
return "start/" + s;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,7 @@ import org.springframework.test.context.TestPropertySource;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
@SpringBootTest(
|
||||
classes = { WaitUntilZipkinIsUpConfig.class, SampleZipkinApplication.class },
|
||||
@SpringBootTest(classes = { WaitUntilZipkinIsUpConfig.class, SampleZipkinApplication.class },
|
||||
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
||||
@TestPropertySource(properties = { "sample.zipkin.enabled=true" })
|
||||
public class ZipkinTests extends AbstractIntegrationTest {
|
||||
@@ -90,9 +89,8 @@ public class ZipkinTests extends AbstractIntegrationTest {
|
||||
|
||||
long traceId = new Random().nextLong();
|
||||
|
||||
await().atMost(10, SECONDS)
|
||||
.untilAsserted(() -> httpMessageWithTraceIdInHeadersIsSuccessfullySent(
|
||||
this.sampleAppUrl + "/hi2", traceId).run());
|
||||
await().atMost(10, SECONDS).untilAsserted(
|
||||
() -> httpMessageWithTraceIdInHeadersIsSuccessfullySent(this.sampleAppUrl + "/hi2", traceId).run());
|
||||
|
||||
spansSentToZipkin(zipkin, traceId);
|
||||
}
|
||||
@@ -101,20 +99,15 @@ public class ZipkinTests extends AbstractIntegrationTest {
|
||||
return APP_NAME;
|
||||
}
|
||||
|
||||
void spansSentToZipkin(MockWebServer zipkin, long traceId)
|
||||
throws InterruptedException {
|
||||
void spansSentToZipkin(MockWebServer zipkin, long traceId) throws InterruptedException {
|
||||
RecordedRequest request = zipkin.takeRequest();
|
||||
List<Span> spans = SpanBytesDecoder.JSON_V2
|
||||
.decodeList(request.getBody().readByteArray());
|
||||
List<Span> spans = SpanBytesDecoder.JSON_V2.decodeList(request.getBody().readByteArray());
|
||||
List<String> traceIdsNotFoundInZipkin = traceIdsNotFoundInZipkin(spans, traceId);
|
||||
List<String> serviceNamesNotFoundInZipkin = serviceNamesNotFoundInZipkin(spans);
|
||||
List<String> tagsNotFoundInZipkin = hasRequiredTag(spans);
|
||||
log.info(String.format("The following trace IDs were not found in Zipkin %s",
|
||||
traceIdsNotFoundInZipkin));
|
||||
log.info(String.format("The following services were not found in Zipkin %s",
|
||||
serviceNamesNotFoundInZipkin));
|
||||
log.info(String.format("The following tags were not found in Zipkin %s",
|
||||
tagsNotFoundInZipkin));
|
||||
log.info(String.format("The following trace IDs were not found in Zipkin %s", traceIdsNotFoundInZipkin));
|
||||
log.info(String.format("The following services were not found in Zipkin %s", serviceNamesNotFoundInZipkin));
|
||||
log.info(String.format("The following tags were not found in Zipkin %s", tagsNotFoundInZipkin));
|
||||
then(traceIdsNotFoundInZipkin).isEmpty();
|
||||
then(serviceNamesNotFoundInZipkin).isEmpty();
|
||||
then(tagsNotFoundInZipkin).isEmpty();
|
||||
@@ -123,17 +116,15 @@ public class ZipkinTests extends AbstractIntegrationTest {
|
||||
|
||||
List<String> traceIdsNotFoundInZipkin(List<Span> spans, long traceId) {
|
||||
String traceIdString = SpanUtil.idToHex(traceId);
|
||||
Optional<String> traceIds = spans.stream().map(Span::traceId)
|
||||
.filter(traceIdString::equals).findFirst();
|
||||
return traceIds.isPresent() ? Collections.emptyList()
|
||||
: Collections.singletonList(traceIdString);
|
||||
Optional<String> traceIds = spans.stream().map(Span::traceId).filter(traceIdString::equals).findFirst();
|
||||
return traceIds.isPresent() ? Collections.emptyList() : Collections.singletonList(traceIdString);
|
||||
}
|
||||
|
||||
List<String> serviceNamesNotFoundInZipkin(List<Span> spans) {
|
||||
List<String> localServiceNames = spans.stream().map(Span::localServiceName)
|
||||
.filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
List<String> remoteServiceNames = spans.stream().map(Span::remoteServiceName)
|
||||
.filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
List<String> localServiceNames = spans.stream().map(Span::localServiceName).filter(Objects::nonNull).distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<String> remoteServiceNames = spans.stream().map(Span::remoteServiceName).filter(Objects::nonNull)
|
||||
.distinct().collect(Collectors.toList());
|
||||
List<String> names = new ArrayList<>();
|
||||
names.addAll(localServiceNames);
|
||||
names.addAll(remoteServiceNames);
|
||||
@@ -142,11 +133,9 @@ public class ZipkinTests extends AbstractIntegrationTest {
|
||||
|
||||
List<String> hasRequiredTag(List<Span> spans) {
|
||||
String key = getRequiredTagKey();
|
||||
Optional<String> keys = spans.stream()
|
||||
.flatMap(span -> span.tags().keySet().stream()).filter(key::equals)
|
||||
Optional<String> keys = spans.stream().flatMap(span -> span.tags().keySet().stream()).filter(key::equals)
|
||||
.findFirst();
|
||||
return keys.isPresent() ? Collections.emptyList()
|
||||
: Collections.singletonList(key);
|
||||
return keys.isPresent() ? Collections.emptyList() : Collections.singletonList(key);
|
||||
}
|
||||
|
||||
String getRequiredTagKey() {
|
||||
|
||||
@@ -35,8 +35,7 @@ import org.springframework.web.client.RestTemplate;
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@RestController
|
||||
public class SampleController
|
||||
implements ApplicationListener<ServletWebServerInitializedEvent> {
|
||||
public class SampleController implements ApplicationListener<ServletWebServerInitializedEvent> {
|
||||
|
||||
private static final Log log = LogFactory.getLog(SampleController.class);
|
||||
|
||||
@@ -58,8 +57,7 @@ public class SampleController
|
||||
log.info("hi!");
|
||||
Thread.sleep(this.random.nextInt(1000));
|
||||
|
||||
String s = this.restTemplate
|
||||
.getForObject("http://localhost:" + this.port + "/hi2", String.class);
|
||||
String s = this.restTemplate.getForObject("http://localhost:" + this.port + "/hi2", String.class);
|
||||
return "hi/" + s;
|
||||
}
|
||||
|
||||
@@ -71,8 +69,7 @@ public class SampleController
|
||||
log.info("call");
|
||||
int millis = SampleController.this.random.nextInt(1000);
|
||||
Thread.sleep(millis);
|
||||
SampleController.this.tracer.currentSpan().tag("callable-sleep-millis",
|
||||
String.valueOf(millis));
|
||||
SampleController.this.tracer.currentSpan().tag("callable-sleep-millis", String.valueOf(millis));
|
||||
Span span = SampleController.this.tracer.currentSpan();
|
||||
return "async hi: " + span;
|
||||
}
|
||||
@@ -104,8 +101,7 @@ public class SampleController
|
||||
Thread.sleep(millis);
|
||||
this.tracer.currentSpan().tag("random-sleep-millis", String.valueOf(millis));
|
||||
|
||||
String s = this.restTemplate
|
||||
.getForObject("http://localhost:" + this.port + "/call", String.class);
|
||||
String s = this.restTemplate.getForObject("http://localhost:" + this.port + "/call", String.class);
|
||||
span.finish();
|
||||
return "traced/" + s;
|
||||
}
|
||||
@@ -118,8 +114,7 @@ public class SampleController
|
||||
Thread.sleep(millis);
|
||||
this.tracer.currentSpan().tag("random-sleep-millis", String.valueOf(millis));
|
||||
|
||||
String s = this.restTemplate
|
||||
.getForObject("http://localhost:" + this.port + "/call", String.class);
|
||||
String s = this.restTemplate.getForObject("http://localhost:" + this.port + "/call", String.class);
|
||||
return "start/" + s;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user