Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 31 additions & 17 deletions instrumentation/vertx/vertx-web-3.0/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,59 @@ dependencies {
testInstrumentation(project(":instrumentation:jdbc:javaagent"))
}

val testLatestDeps = findProperty("testLatestDeps") as Boolean

testing {
suites {
val version3Test by registering(JvmTestSuite::class) {
dependencies {
implementation(project(":instrumentation:vertx:vertx-web-3.0:testing"))

implementation("io.vertx:vertx-web:3.0.0")
implementation("io.vertx:vertx-jdbc-client:3.0.0")
implementation("io.vertx:vertx-codegen:3.0.0")
implementation("io.vertx:vertx-docgen:3.0.0")
val version = if (testLatestDeps) "3.+" else "3.0.0"
implementation("io.vertx:vertx-web:$version")
implementation("io.vertx:vertx-jdbc-client:$version")
implementation("io.vertx:vertx-codegen:$version")
implementation("io.vertx:vertx-docgen:$version")
}
}

val latestDepTest by registering(JvmTestSuite::class) {
val version41Test by registering(JvmTestSuite::class) {
dependencies {
implementation(project(":instrumentation:vertx:vertx-web-3.0:testing"))

implementation("io.vertx:vertx-web:4.+")
implementation("io.vertx:vertx-jdbc-client:4.+")
implementation("io.vertx:vertx-codegen:4.+")
val version = if (testLatestDeps) "4.+" else "4.1.0"
implementation("io.vertx:vertx-web:$version")
implementation("io.vertx:vertx-jdbc-client:$version")
implementation("io.vertx:vertx-codegen:$version")
}
}

val version5Test by registering(JvmTestSuite::class) {
dependencies {
implementation(project(":instrumentation:vertx:vertx-web-3.0:testing"))

val version = if (testLatestDeps) "latest.release" else "5.0.0"
implementation("io.vertx:vertx-web:$version")
implementation("io.vertx:vertx-jdbc-client:$version")
implementation("io.vertx:vertx-codegen:$version")
}
}
}
}

val testLatestDeps = findProperty("testLatestDeps") as Boolean

tasks {
if (testLatestDeps) {
// disable regular test running and compiling tasks when latest dep test task is run
named("test") {
named("compileVersion5TestJava", JavaCompile::class).configure {
options.release.set(11)
}
val testJavaVersion =
gradle.startParameter.projectProperties.get("testJavaVersion")?.let(JavaVersion::toVersion)
?: JavaVersion.current()
if (!testJavaVersion.isCompatibleWith(JavaVersion.VERSION_11)) {
named("version5Test", Test::class).configure {
enabled = false
}
}

named("latestDepTest") {
enabled = testLatestDeps
}

check {
dependsOn(testing.suites)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;

class VertxLatestHttpServerTest extends AbstractVertxHttpServerTest {
class Vertx41HttpServerTest extends AbstractVertxHttpServerTest {

@Override
protected Class<? extends AbstractVerticle> verticle() {
return VertxLatestWebServer.class;
return Vertx41WebServer.class;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.vertx.core.http.HttpServerResponse;
import io.vertx.ext.web.Router;

public class VertxLatestWebServer extends AbstractVertxWebServer {
public class Vertx41WebServer extends AbstractVertxWebServer {

@Override
public void end(HttpServerResponse response) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.netty.handler.codec.haproxy;

// instrumentation fails without this class
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
public class HAProxyMessage {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.netty.handler.codec.haproxy;

// instrumentation fails without this class
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
public class HAProxyProxiedProtocol {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.vertx;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.core.json.JsonObject;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

class Vertx5HttpServerTest extends AbstractVertxHttpServerTest {

@Override
protected Class<? extends AbstractVerticle> verticle() {
return Vertx5WebServer.class;
}

@Override
protected Vertx setupServer()
throws ExecutionException, InterruptedException, TimeoutException, NoSuchMethodException {
Vertx server =
Vertx.vertx(
new VertxOptions()
// Useful for debugging:
// .setBlockedThreadCheckInterval(Integer.MAX_VALUE)
);
CompletableFuture<Void> future = new CompletableFuture<>();

server
.deployVerticle(
verticle().getName(),
new DeploymentOptions()
.setConfig(
new JsonObject()
.put(AbstractVertxWebServer.CONFIG_HTTP_SERVER_PORT, (Object) port))
.setInstances(3))
.onComplete(
res -> {
if (!res.succeeded()) {
throw new IllegalStateException("Cannot deploy server Verticle", res.cause());
}
future.complete(null);
});

future.get(30, TimeUnit.SECONDS);
return server;
}

@Override
protected void stopServer(Vertx server) throws Exception {
server.close();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.vertx;

import io.vertx.core.Promise;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.ext.web.Router;

public class Vertx5WebServer extends AbstractVertxWebServer {

@Override
public void end(HttpServerResponse response) {
response.end();
}

@Override
public void end(HttpServerResponse response, String message) {
response.end(message);
}

@Override
public void start(Promise<Void> startPromise) {
int port = config().getInteger(CONFIG_HTTP_SERVER_PORT);
Router router = buildRouter();
Router mainRouter = Router.router(vertx);
mainRouter.route("/vertx-app/*").subRouter(router);

vertx
.createHttpServer()
.requestHandler(mainRouter)
.listen(port)
.onComplete(it -> startPromise.complete());
}
}
Loading