Preparation for e2e propagators test
MODIFY
smoke-tests/springboot/build.gradle
smoke-tests/springboot/build.gradle
@@ -23,6 +23,7 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'io.opentelemetry:opentelemetry-extension-annotations:0.11.0'
+ implementation 'io.opentelemetry:opentelemetry-api:0.11.0'
}
compileJava {

ADD
smoke-tests/springboot/src/main/java/io/opentelemetry/smoketest/springboot/controller/PropagatingController.java
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.opentelemetry.smoketest.springboot.controller;
+
+import io.opentelemetry.api.trace.Span;
+import java.net.URI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
+
+/**
+ * This controller demonstrates that context propagation works across http calls.
+ * Calling <code>/front</code> should return a string which contains two traceId separated by ";".
+ * First traceId was reported by <code>/front</code> handler, the second one was returned by
+ * <code>/back</code> handler which was called by <code>/front</code>. If context propagation
+ * works correctly, then both values should be the same.
+ */
+@RestController
+public class PropagatingController {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PropagatingController.class);
+
+ private final RestTemplate restTemplate;
+
+ public PropagatingController(RestTemplateBuilder restTemplateBuilder) {
+ this.restTemplate = restTemplateBuilder.build();
+ }
+
+ @RequestMapping("/front")
+ public String front() {
+ URI backend = ServletUriComponentsBuilder
+ .fromCurrentContextPath()
+ .path("/back")
+ .build()
+ .toUri();
+ String backendTraceId = restTemplate.getForObject(backend, String.class);
+ String frontendTraceId = Span.current().getSpanContext().getTraceIdAsHexString();
+ return String.format("%s;%s", frontendTraceId, backendTraceId);
+ }
+
+ @RequestMapping("/back")
+ public String back() {
+ return Span.current().getSpanContext().getTraceIdAsHexString();
+ }
+}

MODIFY
smoke-tests/src/test/groovy/io/opentelemetry/smoketest/SpringBootSmokeTest.groovy
smoke-tests/src/test/groovy/io/opentelemetry/smoketest/SpringBootSmokeTest.groovy
@@ -7,8 +7,8 @@ package io.opentelemetry.smoketest
import static java.util.stream.Collectors.toSet
-import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest
import io.opentelemetry.api.trace.TraceId
+import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest
import java.util.jar.Attributes
import java.util.jar.JarFile
import okhttp3.Request
@@ -17,7 +17,7 @@ import spock.lang.Unroll
class SpringBootSmokeTest extends SmokeTest {
protected String getTargetImage(int jdk) {
- "open-telemetry-docker-dev.bintray.io/java/smoke-springboot-jdk$jdk:latest"
+ "open-telemetry-docker-dev.bintray.io/java/smoke-springboot-jdk$jdk:20201120.373623860"
}
@Unroll

Preparation for e2e propagators test (#1781)