Build and test extensions with Java 8
MODIFY
examples/distro/build.gradle
examples/distro/build.gradle
@@ -47,7 +47,7 @@ subprojects {
}
compileJava {
- options.release.set(11)
+ options.release.set(8)
}
}
}

MODIFY
examples/distro/custom/src/main/java/com/example/javaagent/DemoPropertySource.java
examples/distro/custom/src/main/java/com/example/javaagent/DemoPropertySource.java
package com.example.javaagent;
import io.opentelemetry.javaagent.extension.config.ConfigPropertySource;
+import java.util.HashMap;
import java.util.Map;
/**
@@ -13,9 +14,10 @@ public class DemoPropertySource implements ConfigPropertySource {
@Override
public Map<String, String> getProperties() {
- return Map.of(
- "otel.exporter.otlp.endpoint", "http://backend:8080",
- "otel.exporter.otlp.insecure", "true",
- "otel.config.max.attrs", "16");
+ Map<String, String> properties = new HashMap<>();
+ properties.put("otel.exporter.otlp.endpoint", "http://backend:8080");
+ properties.put("otel.exporter.otlp.insecure", "true");
+ properties.put("otel.config.max.attrs", "16");
+ return properties;
}
}

MODIFY
examples/distro/smoke-tests/src/test/java/com/example/javaagent/smoketest/SpringBootSmokeTest.java
examples/distro/smoke-tests/src/test/java/com/example/javaagent/smoketest/SpringBootSmokeTest.java
@@ -22,7 +22,7 @@ class SpringBootSmokeTest extends SmokeTest {
@Test
public void springBootSmokeTestOnJDK() throws IOException, InterruptedException {
- startTarget(11);
+ startTarget(8);
String url = String.format("http://localhost:%d/greeting", target.getMappedPort(8080));
Request request = new Request.Builder().url(url).get().build();

MODIFY
examples/extension/build.gradle
examples/extension/build.gradle
@@ -132,7 +132,7 @@ tasks {
}
compileJava {
- options.release.set(11)
+ options.release.set(8)
}
assemble.dependsOn(shadowJar)

MODIFY
examples/extension/src/main/java/com/example/javaagent/DemoPropertySource.java
examples/extension/src/main/java/com/example/javaagent/DemoPropertySource.java
@@ -2,6 +2,7 @@ package com.example.javaagent;
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.config.ConfigPropertySource;
+import java.util.HashMap;
import java.util.Map;
/**
@@ -15,9 +16,10 @@ public class DemoPropertySource implements ConfigPropertySource {
@Override
public Map<String, String> getProperties() {
- return Map.of(
- "otel.exporter.otlp.endpoint", "http://backend:8080",
- "otel.exporter.otlp.insecure", "true",
- "otel.config.max.attrs", "16");
+ Map<String, String> properties = new HashMap<>();
+ properties.put("otel.exporter.otlp.endpoint", "http://backend:8080");
+ properties.put("otel.exporter.otlp.insecure", "true");
+ properties.put("otel.config.max.attrs", "16");
+ return properties;
}
}

MODIFY
examples/extension/src/test/java/com/example/javaagent/smoketest/IntegrationTest.java
examples/extension/src/test/java/com/example/javaagent/smoketest/IntegrationTest.java
@@ -80,7 +80,7 @@ abstract class IntegrationTest {
private GenericContainer<?> buildTargetContainer(String agentPath, String extensionLocation) {
GenericContainer<?> result =
- new GenericContainer<>(getTargetImage(11))
+ new GenericContainer<>(getTargetImage(8))
.withExposedPorts(8080)
.withNetwork(network)
.withLogConsumer(new Slf4jLogConsumer(logger))

Build and test extensions with Java 8 (#4665)