Remove collector from smoke tests
MODIFY
.github/workflows/pr-smoke-test-fake-backend-images.yml
.github/workflows/pr-smoke-test-fake-backend-images.yml
@@ -67,5 +67,5 @@ jobs:
key: ${{ runner.os }}-gradle-wrapper-cache-${{ hashFiles('smoke-tests/fake-backend/gradle/wrapper/gradle-wrapper.properties') }}
- name: Build Docker Image
- run: ./gradlew windowsBackendImageBuild windowsCollectorImageBuild
+ run: ./gradlew windowsBackendImageBuild
working-directory: smoke-tests/fake-backend

MODIFY
examples/distro/custom/src/main/java/com/example/javaagent/DemoPropertySource.java
examples/distro/custom/src/main/java/com/example/javaagent/DemoPropertySource.java
@@ -14,7 +14,7 @@ public class DemoPropertySource implements ConfigPropertySource {
@Override
public Map<String, String> getProperties() {
return Map.of(
- "otel.exporter.otlp.endpoint", "http://collector:4317",
+ "otel.exporter.otlp.endpoint", "http://backend:8080",
"otel.exporter.otlp.insecure", "true",
"otel.config.max.attrs", "16");
}

MODIFY
examples/distro/settings.gradle
examples/distro/settings.gradle
-rootProject.name = 'opentelemetry-java-instrumentation-demo'
+rootProject.name = 'opentelemetry-java-instrumentation-distro-demo'
include "agent"
include "custom"
include "instrumentation"
include "instrumentation:servlet-3"
include "smoke-tests"
-

MODIFY
examples/distro/smoke-tests/src/test/java/com/example/javaagent/smoketest/SmokeTest.java
examples/distro/smoke-tests/src/test/java/com/example/javaagent/smoketest/SmokeTest.java
@@ -47,7 +47,6 @@ abstract class SmokeTest {
}
private static GenericContainer backend;
- private static GenericContainer collector;
@BeforeAll
static void setupSpec() {
@@ -60,17 +59,6 @@ abstract class SmokeTest {
.withNetworkAliases("backend")
.withLogConsumer(new Slf4jLogConsumer(logger));
backend.start();
-
- collector =
- new GenericContainer<>("otel/opentelemetry-collector-contrib:latest")
- .dependsOn(backend)
- .withNetwork(network)
- .withNetworkAliases("collector")
- .withLogConsumer(new Slf4jLogConsumer(logger))
- .withCopyFileToContainer(
- MountableFile.forClasspathResource("/otel.yaml"), "/etc/otel.yaml")
- .withCommand("--config /etc/otel.yaml");
- collector.start();
}
protected GenericContainer target;
@@ -109,7 +97,6 @@ abstract class SmokeTest {
@AfterAll
static void cleanupSpec() {
backend.stop();
- collector.stop();
}
protected static int countResourcesByValue(

DELETE
examples/distro/smoke-tests/src/test/resources/otel.yaml
-extensions:
- health_check:
- pprof:
- endpoint: 0.0.0.0:1777
- zpages:
- endpoint: 0.0.0.0:55679
-
-receivers:
- otlp:
- protocols:
- grpc:
-
-processors:
- batch:
-
-exporters:
- logging:
- loglevel: debug
- otlp:
- endpoint: backend:8080
- insecure: true
-
-service:
- pipelines:
- traces:
- receivers: [ otlp ]
- processors: [ batch ]
- exporters: [ logging, otlp ]
-
- extensions: [ health_check, pprof, zpages ]

MODIFY
examples/extension/src/main/java/com/example/javaagent/DemoPropertySource.java
examples/extension/src/main/java/com/example/javaagent/DemoPropertySource.java
@@ -16,7 +16,7 @@ public class DemoPropertySource implements ConfigPropertySource {
@Override
public Map<String, String> getProperties() {
return Map.of(
- "otel.exporter.otlp.endpoint", "http://collector:4317",
+ "otel.exporter.otlp.endpoint", "http://backend:8080",
"otel.exporter.otlp.insecure", "true",
"otel.config.max.attrs", "16");
}

MODIFY
examples/extension/src/test/java/com/example/javaagent/smoketest/IntegrationTest.java
examples/extension/src/test/java/com/example/javaagent/smoketest/IntegrationTest.java
@@ -52,7 +52,6 @@ abstract class IntegrationTest {
}
private static GenericContainer backend;
- private static GenericContainer collector;
@BeforeAll
static void setupSpec() {
@@ -65,17 +64,6 @@ abstract class IntegrationTest {
.withNetworkAliases("backend")
.withLogConsumer(new Slf4jLogConsumer(logger));
backend.start();
-
- collector =
- new GenericContainer<>("otel/opentelemetry-collector-contrib:latest")
- .dependsOn(backend)
- .withNetwork(network)
- .withNetworkAliases("collector")
- .withLogConsumer(new Slf4jLogConsumer(logger))
- .withCopyFileToContainer(
- MountableFile.forClasspathResource("/otel.yaml"), "/etc/otel.yaml")
- .withCommand("--config /etc/otel.yaml");
- collector.start();
}
protected GenericContainer<?> target;
@@ -136,7 +124,6 @@ abstract class IntegrationTest {
@AfterAll
static void cleanupSpec() {
backend.stop();
- collector.stop();
}
protected static int countResourcesByValue(

DELETE
examples/extension/src/test/resources/otel.yaml
-extensions:
- health_check:
- pprof:
- endpoint: 0.0.0.0:1777
- zpages:
- endpoint: 0.0.0.0:55679
-
-receivers:
- otlp:
- protocols:
- grpc:
-
-processors:
- batch:
-
-exporters:
- logging:
- loglevel: debug
- otlp:
- endpoint: backend:8080
- insecure: true
-
-service:
- pipelines:
- traces:
- receivers: [ otlp ]
- processors: [ batch ]
- exporters: [ logging, otlp ]
-
- extensions: [ health_check, pprof, zpages ]

MODIFY
smoke-tests/fake-backend/build.gradle
smoke-tests/fake-backend/build.gradle
@@ -62,40 +62,9 @@ task windowsBackendImageBuild(type: DockerBuildImage) {
it.dockerFile = new File(backendDockerBuildDir, "windows.dockerfile")
}
-def collectorDockerBuildDir = new File(project.buildDir, "docker-collector")
-
-task windowsCollectorBinaryDownload(type: Download) {
- doFirst {
- collectorDockerBuildDir.mkdirs()
- }
-
- // TODO (trask) update this to point to new opentelemetry-collector-releases repo
- // this involves making two further changes:
- // * all the artifacts in the new repo now have version in their name (so no single url for "latest")
- // * the artifacts are now tar.gz format, so need to extract the exe
- // note: version is hardcoded below because that is last version in the collector repo that has the releases attached
- src("https://github.com/open-telemetry/opentelemetry-collector/releases/download/v0.33.0/otelcol_windows_amd64.exe")
- dest(collectorDockerBuildDir)
-}
-
-task windowsCollectorImagePrepare(type: Copy) {
- dependsOn(windowsCollectorBinaryDownload)
- into(collectorDockerBuildDir)
- from("src/docker/collector")
-}
-
-task windowsCollectorImageBuild(type: DockerBuildImage) {
- dependsOn(windowsCollectorImagePrepare)
- inputDir = collectorDockerBuildDir
-
- it.images.add "ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-collector-windows:$extraTag"
- it.dockerFile = new File(collectorDockerBuildDir, "windows.dockerfile")
-}
-
tasks.create("dockerPush", DockerPushImage) {
group = "publishing"
description = "Push all Docker images for the test backend"
- dependsOn(windowsBackendImageBuild, windowsCollectorImageBuild)
- images.set(["ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-fake-backend-windows:$extraTag",
- "ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-collector-windows:$extraTag"])
+ dependsOn(windowsBackendImageBuild)
+ images.set(["ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-fake-backend-windows:$extraTag"])
}

DELETE
smoke-tests/fake-backend/src/docker/collector/windows.dockerfile
-FROM mcr.microsoft.com/windows/servercore:ltsc2019
-COPY otelcol_windows_amd64.exe /otelcol_windows_amd64.exe
-ENV NO_WINDOWS_SERVICE=1
-ENTRYPOINT /otelcol_windows_amd64.exe

DELETE
smoke-tests/src/test/groovy/io/opentelemetry/smoketest/JaegerExporterSmokeTest.groovy
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.smoketest
-
-import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest
-import spock.lang.IgnoreIf
-
-import java.util.jar.Attributes
-import java.util.jar.JarFile
-
-import static java.util.stream.Collectors.toSet
-
-@IgnoreIf({ os.windows })
-class JaegerExporterSmokeTest extends SmokeTest {
-
- protected String getTargetImage(String jdk) {
- "ghcr.io/open-telemetry/java-test-containers:smoke-springboot-jdk$jdk-20210915.1238472439"
- }
-
- @Override
- protected Map<String, String> getExtraEnv() {
- return [
- "OTEL_TRACES_EXPORTER" : "jaeger",
- "OTEL_EXPORTER_JAEGER_ENDPOINT": "http://collector:14250"
- ]
- }
-
- def "spring boot smoke test with jaeger grpc"() {
- setup:
- startTarget(11)
-
- def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION)
-
- when:
- def response = client().get("/greeting").aggregate().join()
- Collection<ExportTraceServiceRequest> traces = waitForTraces()
-
- then:
- response.contentUtf8() == "Hi!"
- countSpansByName(traces, '/greeting') == 1
- countSpansByName(traces, 'WebController.greeting') == 1
- countSpansByName(traces, 'WebController.withSpan') == 1
-
- [currentAgentVersion] as Set == findResourceAttribute(traces, "telemetry.auto.version")
- .map { it.stringValue }
- .collect(toSet())
-
- cleanup:
- stopTarget()
-
- }
-
-}

DELETE
smoke-tests/src/test/groovy/io/opentelemetry/smoketest/ZipkinExporterSmokeTest.groovy
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.smoketest
-
-import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest
-import spock.lang.IgnoreIf
-
-@IgnoreIf({ os.windows })
-class ZipkinExporterSmokeTest extends SmokeTest {
-
- protected String getTargetImage(String jdk) {
- "ghcr.io/open-telemetry/java-test-containers:smoke-springboot-jdk$jdk-20210915.1238472439"
- }
-
- @Override
- protected Map<String, String> getExtraEnv() {
- return [
- "OTEL_TRACES_EXPORTER" : "zipkin",
- "OTEL_EXPORTER_ZIPKIN_ENDPOINT": "http://collector:9411/api/v2/spans"
- ]
- }
-
- def "spring boot smoke test with Zipkin"() {
- setup:
- startTarget(11)
-
- // def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION)
-
- when:
- def response = client().get("/greeting").aggregate().join()
- Collection<ExportTraceServiceRequest> traces = waitForTraces()
-
- then:
- response.contentUtf8() == "Hi!"
- countSpansByName(traces, '/greeting') == 1
- countSpansByName(traces, 'webcontroller.greeting') == 1
- countSpansByName(traces, 'webcontroller.withspan') == 1
-
- //This is currently broken, see https://github.com/open-telemetry/opentelemetry-java/issues/1970
-// [currentAgentVersion] as Set == findResourceAttribute(traces, "telemetry.auto.version")
-// .map { it.stringValue }
-// .collect(toSet())
-
- cleanup:
- stopTarget()
-
- }
-
-}

MODIFY
smoke-tests/src/test/java/io/opentelemetry/smoketest/AbstractTestContainerManager.java
smoke-tests/src/test/java/io/opentelemetry/smoketest/AbstractTestContainerManager.java
@@ -13,7 +13,6 @@ public abstract class AbstractTestContainerManager implements TestContainerManag
protected static final int BACKEND_PORT = 8080;
protected static final String BACKEND_ALIAS = "backend";
- protected static final String COLLECTOR_ALIAS = "collector";
protected static final String TARGET_AGENT_FILENAME = "opentelemetry-javaagent.jar";
protected static final String COLLECTOR_CONFIG_RESOURCE = "/otel.yaml";
@@ -28,7 +27,7 @@ public abstract class AbstractTestContainerManager implements TestContainerManag
environment.put("OTEL_BSP_MAX_EXPORT_BATCH_SIZE", "1");
environment.put("OTEL_BSP_SCHEDULE_DELAY", "10ms");
environment.put("OTEL_IMR_EXPORT_INTERVAL", "1000");
- environment.put("OTEL_EXPORTER_OTLP_ENDPOINT", "http://" + COLLECTOR_ALIAS + ":4317");
+ environment.put("OTEL_EXPORTER_OTLP_ENDPOINT", "http://" + BACKEND_ALIAS + ":8080");
environment.put("OTEL_RESOURCE_ATTRIBUTES", "service.name=smoke-test");
environment.put("OTEL_JAVAAGENT_DEBUG", "true");
return environment;

MODIFY
smoke-tests/src/test/java/io/opentelemetry/smoketest/LinuxTestContainerManager.java
smoke-tests/src/test/java/io/opentelemetry/smoketest/LinuxTestContainerManager.java
@@ -22,12 +22,10 @@ import org.testcontainers.utility.MountableFile;
public class LinuxTestContainerManager extends AbstractTestContainerManager {
private static final Logger logger = LoggerFactory.getLogger(LinuxTestContainerManager.class);
- private static final Logger collectorLogger = LoggerFactory.getLogger("Collector");
private static final Logger backendLogger = LoggerFactory.getLogger("Backend");
private final Network network = Network.newNetwork();
private GenericContainer<?> backend = null;
- private GenericContainer<?> collector = null;
private GenericContainer<?> target = null;
@Override
@@ -42,17 +40,6 @@ public class LinuxTestContainerManager extends AbstractTestContainerManager {
.withNetworkAliases(BACKEND_ALIAS)
.withLogConsumer(new Slf4jLogConsumer(backendLogger));
backend.start();
-
- collector =
- new GenericContainer<>(DockerImageName.parse("otel/opentelemetry-collector-contrib:latest"))
- .dependsOn(backend)
- .withNetwork(network)
- .withNetworkAliases(COLLECTOR_ALIAS)
- .withLogConsumer(new Slf4jLogConsumer(collectorLogger))
- .withCopyFileToContainer(
- MountableFile.forClasspathResource(COLLECTOR_CONFIG_RESOURCE), "/etc/otel.yaml")
- .withCommand("--config /etc/otel.yaml");
- collector.start();
}
@Override
@@ -62,11 +49,6 @@ public class LinuxTestContainerManager extends AbstractTestContainerManager {
backend = null;
}
- if (collector != null) {
- collector.stop();
- collector = null;
- }
-
network.close();
}

MODIFY
smoke-tests/src/test/java/io/opentelemetry/smoketest/windows/WindowsTestContainerManager.java
smoke-tests/src/test/java/io/opentelemetry/smoketest/windows/WindowsTestContainerManager.java
@@ -52,11 +52,9 @@ import org.testcontainers.containers.output.OutputFrame;
public class WindowsTestContainerManager extends AbstractTestContainerManager {
private static final Logger logger = LoggerFactory.getLogger(WindowsTestContainerManager.class);
- private static final Logger collectorLogger = LoggerFactory.getLogger("Collector");
private static final Logger backendLogger = LoggerFactory.getLogger("Backend");
private static final String NPIPE_URI = "npipe:////./pipe/docker_engine";
- private static final String COLLECTOR_CONFIG_FILE_PATH = "/collector-config.yml";
private final DockerClient client =
DockerClientImpl.getInstance(
@@ -65,7 +63,6 @@ public class WindowsTestContainerManager extends AbstractTestContainerManager {
@Nullable private String natNetworkId = null;
@Nullable private Container backend;
- @Nullable private Container collector;
@Nullable private Container target;
@Override
@@ -104,44 +101,12 @@ public class WindowsTestContainerManager extends AbstractTestContainerManager {
new HttpWaiter(BACKEND_PORT, "/health", Duration.ofSeconds(60)),
/* inspect= */ true,
backendLogger);
-
- String collectorImageName =
- "ghcr.io/open-telemetry/java-test-containers:collector" + backendSuffix;
- if (!imageExists(collectorImageName)) {
- pullImage(collectorImageName);
- }
- collector =
- startContainer(
- collectorImageName,
- command ->
- command
- .withAliases(COLLECTOR_ALIAS)
- .withHostConfig(
- HostConfig.newHostConfig()
- .withAutoRemove(true)
- .withNetworkMode(natNetworkId))
- .withCmd("--config", COLLECTOR_CONFIG_FILE_PATH),
- containerId -> {
- try (InputStream configFileStream =
- this.getClass().getResourceAsStream(COLLECTOR_CONFIG_RESOURCE)) {
- copyFileToContainer(
- containerId, IOUtils.toByteArray(configFileStream), COLLECTOR_CONFIG_FILE_PATH);
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- },
- new NoOpWaiter(),
- /* inspect= */ false,
- collectorLogger);
}
@Override
protected void stopEnvironment() {
stopTarget();
- killContainer(collector);
- collector = null;
-
killContainer(backend);
backend = null;

DELETE
smoke-tests/src/test/resources/otel.yaml
-extensions:
- health_check:
- pprof:
- endpoint: 0.0.0.0:1777
- zpages:
- endpoint: 0.0.0.0:55679
-
-receivers:
- otlp:
- protocols:
- grpc:
- zipkin:
- jaeger:
- protocols:
- grpc:
-
-processors:
- batch:
-
-exporters:
- logging/logging_debug:
- loglevel: debug
- logging/logging_info:
- loglevel: info
- otlp:
- endpoint: backend:8080
- insecure: true
-
-service:
- pipelines:
- traces:
- receivers: [ otlp, zipkin, jaeger ]
- processors: [ batch ]
- exporters: [ logging/logging_debug, otlp ]
- metrics:
- receivers: [ otlp ]
- processors: [ batch ]
- exporters: [ logging/logging_info, otlp ]
-
- extensions: [ health_check, pprof, zpages ]

Remove collector from smoke tests (#4186)