-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@UnlessBuildProperty to suppress default instance
Co-authored-by: Martin Kouba <[email protected]>
- Loading branch information
Showing
7 changed files
with
77 additions
and
4 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
55 changes: 55 additions & 0 deletions
55
...oyment/src/test/java/io/quarkus/micrometer/deployment/export/NoDefaultPrometheusTest.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,55 @@ | ||
package io.quarkus.micrometer.deployment.export; | ||
|
||
import java.util.Set; | ||
|
||
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.micrometer.core.instrument.MeterRegistry; | ||
import io.micrometer.core.instrument.composite.CompositeMeterRegistry; | ||
import io.micrometer.prometheus.PrometheusMeterRegistry; | ||
import io.quarkus.micrometer.test.Util; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class NoDefaultPrometheusTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.setFlatClassPath(true) | ||
.withConfigurationResource("test-logging.properties") | ||
.overrideConfigKey("quarkus.micrometer.binder-enabled-default", "false") | ||
.overrideConfigKey("quarkus.micrometer.export.prometheus.enabled", "true") | ||
.overrideConfigKey("quarkus.micrometer.export.prometheus.default-registry", "false") | ||
.overrideConfigKey("quarkus.micrometer.registry-enabled-default", "false") | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Util.class, | ||
PrometheusRegistryProcessor.REGISTRY_CLASS, | ||
SecondPrometheusProvider.class)); | ||
|
||
@Inject | ||
MeterRegistry registry; | ||
|
||
@Inject | ||
PrometheusMeterRegistry promRegistry; | ||
|
||
@Test | ||
public void testMeterRegistryPresent() { | ||
// Prometheus is enabled (only registry) | ||
Assertions.assertNotNull(registry, "A registry should be configured"); | ||
Set<MeterRegistry> subRegistries = ((CompositeMeterRegistry) registry).getRegistries(); | ||
|
||
PrometheusMeterRegistry subPromRegistry = (PrometheusMeterRegistry) subRegistries.iterator().next(); | ||
Assertions.assertEquals(PrometheusMeterRegistry.class, subPromRegistry.getClass(), "Should be PrometheusMeterRegistry"); | ||
Assertions.assertEquals(subPromRegistry, promRegistry, | ||
"The only MeterRegistry should be the same bean as the PrometheusMeterRegistry, found " + subRegistries); | ||
|
||
String result = promRegistry.scrape(); | ||
Assertions.assertTrue(result.contains("customKey=\"customValue\""), | ||
"Scrape result should contain common tags from the custom registry configuration. Found\n" + result); | ||
|
||
} | ||
} |
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
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