-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14750 from ebullient/http-server
Micrometer: rename vertx options to http-server
- Loading branch information
Showing
33 changed files
with
576 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...ment/src/test/java/io/quarkus/micrometer/deployment/binder/VertxWithHttpDisabledTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package io.quarkus.micrometer.deployment.binder; | ||
|
||
import javax.enterprise.inject.Instance; | ||
import javax.inject.Inject; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.micrometer.runtime.binder.HttpBinderConfiguration; | ||
import io.quarkus.micrometer.runtime.binder.vertx.VertxMeterBinderAdapter; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.vertx.core.http.HttpServerOptions; | ||
import io.vertx.core.net.SocketAddress; | ||
|
||
public class VertxWithHttpDisabledTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withConfigurationResource("test-logging.properties") | ||
.overrideConfigKey("quarkus.micrometer.binder-enabled-default", "false") | ||
.overrideConfigKey("quarkus.micrometer.binder.vertx.enabled", "true") | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); | ||
|
||
@Inject | ||
Instance<VertxMeterBinderAdapter> vertxMeterBinderAdapterInstance; | ||
|
||
@Inject | ||
HttpBinderConfiguration httpBinderConfiguration; | ||
|
||
@Test | ||
public void testVertxMetricsWithoutHttp() throws Exception { | ||
Assertions.assertTrue(vertxMeterBinderAdapterInstance.isResolvable()); | ||
VertxMeterBinderAdapter adapter = vertxMeterBinderAdapterInstance.get(); | ||
|
||
// HttpServerMetrics should not be created (null returned) because | ||
// Http server metrics are disabled | ||
Assertions.assertNull(adapter.createHttpServerMetrics(new HttpServerOptions(), new SocketAddress() { | ||
@Override | ||
public String host() { | ||
return "a.b.c"; | ||
} | ||
|
||
@Override | ||
public int port() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public String path() { | ||
return null; | ||
} | ||
})); | ||
|
||
Assertions.assertFalse(httpBinderConfiguration.isServerEnabled()); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...yment/src/test/java/io/quarkus/micrometer/deployment/binder/VertxWithHttpEnabledTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package io.quarkus.micrometer.deployment.binder; | ||
|
||
import java.util.Map; | ||
import java.util.regex.Pattern; | ||
|
||
import javax.enterprise.inject.Instance; | ||
import javax.inject.Inject; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.micrometer.runtime.binder.HttpBinderConfiguration; | ||
import io.quarkus.micrometer.runtime.binder.vertx.VertxMeterBinderAdapter; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.vertx.core.http.HttpServerOptions; | ||
import io.vertx.core.net.SocketAddress; | ||
import io.vertx.core.spi.metrics.HttpServerMetrics; | ||
|
||
public class VertxWithHttpEnabledTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withConfigurationResource("test-logging.properties") | ||
.overrideConfigKey("quarkus.micrometer.binder-enabled-default", "false") | ||
.overrideConfigKey("quarkus.micrometer.binder.http-server.enabled", "true") | ||
.overrideConfigKey("quarkus.micrometer.binder.http-server.ignore-patterns", "/http") | ||
.overrideConfigKey("quarkus.micrometer.binder.vertx.enabled", "true") | ||
.overrideConfigKey("quarkus.micrometer.binder.vertx.match-patterns", "/one=/two") | ||
.overrideConfigKey("quarkus.micrometer.binder.vertx.ignore-patterns", "/two") | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); | ||
|
||
@Inject | ||
Instance<VertxMeterBinderAdapter> vertxMeterBinderAdapterInstance; | ||
|
||
@Inject | ||
HttpBinderConfiguration httpBinderConfiguration; | ||
|
||
@Test | ||
public void testMetricFactoryCreatedMetrics() throws Exception { | ||
Assertions.assertTrue(vertxMeterBinderAdapterInstance.isResolvable()); | ||
VertxMeterBinderAdapter adapter = vertxMeterBinderAdapterInstance.get(); | ||
|
||
HttpServerMetrics metrics = adapter.createHttpServerMetrics(new HttpServerOptions(), new SocketAddress() { | ||
@Override | ||
public String host() { | ||
return "a.b.c"; | ||
} | ||
|
||
@Override | ||
public int port() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public String path() { | ||
return null; | ||
} | ||
}); | ||
|
||
Assertions.assertNotNull(metrics); | ||
Assertions.assertTrue(httpBinderConfiguration.isServerEnabled()); | ||
|
||
// prefer http-server.ignore-patterns | ||
Assertions.assertEquals(1, httpBinderConfiguration.getServerIgnorePatterns().size()); | ||
Pattern p = httpBinderConfiguration.getServerIgnorePatterns().get(0); | ||
Assertions.assertTrue(p.matcher("/http").matches()); | ||
|
||
// Use vertx.match-patterns (http-server version is missing) | ||
Assertions.assertEquals(1, httpBinderConfiguration.getServerMatchPatterns().size()); | ||
Map.Entry<Pattern, String> entry = httpBinderConfiguration.getServerMatchPatterns().entrySet().iterator().next(); | ||
Assertions.assertTrue(entry.getKey().matcher("/one").matches()); | ||
Assertions.assertEquals("/two", entry.getValue()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.