-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 #32050 from radcortez/otel-config
Move OTel configuration to use @ConfigMapping
- Loading branch information
Showing
36 changed files
with
552 additions
and
442 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
52 changes: 52 additions & 0 deletions
52
...va/io/quarkus/opentelemetry/deployment/NonAppEndpointsEnabledLegacyConfigurationTest.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,52 @@ | ||
package io.quarkus.opentelemetry.deployment; | ||
|
||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.opentelemetry.deployment.common.TestSpanExporter; | ||
import io.quarkus.opentelemetry.deployment.common.TestSpanExporterProvider; | ||
import io.quarkus.opentelemetry.deployment.common.TracerRouter; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class NonAppEndpointsEnabledLegacyConfigurationTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClass(TracerRouter.class) | ||
.addClasses(TestSpanExporter.class, TestSpanExporterProvider.class) | ||
.addAsResource(new StringAsset(TestSpanExporterProvider.class.getCanonicalName()), | ||
"META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider")) | ||
.withConfigurationResource("application-default.properties") | ||
.overrideConfigKey("quarkus.opentelemetry.tracer.suppress-non-application-uris", "false"); | ||
|
||
@Inject | ||
TestSpanExporter testSpanExporter; | ||
|
||
@Test | ||
void testHealthEndpointNotTraced() throws InterruptedException { | ||
RestAssured.when().get("/q/health").then() | ||
.statusCode(200) | ||
.body(containsString("\"status\": \"UP\"")); | ||
|
||
RestAssured.when().get("/q/health/live").then() | ||
.statusCode(200) | ||
.body(containsString("\"status\": \"UP\"")); | ||
|
||
RestAssured.when().get("/q/health/ready").then() | ||
.statusCode(200) | ||
.body(containsString("\"status\": \"UP\"")); | ||
|
||
RestAssured.when().get("/tracer").then() | ||
.statusCode(200) | ||
.body(is("Hello Tracer!")); | ||
|
||
testSpanExporter.assertSpanCount(5); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...c/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryLegacyConfigurationTest.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,57 @@ | ||
package io.quarkus.opentelemetry.deployment; | ||
|
||
import static java.lang.Boolean.FALSE; | ||
import static java.lang.Boolean.TRUE; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.opentelemetry.runtime.config.build.OTelBuildConfig; | ||
import io.quarkus.opentelemetry.runtime.config.build.exporter.OtlpExporterBuildConfig; | ||
import io.quarkus.opentelemetry.runtime.config.runtime.OTelRuntimeConfig; | ||
import io.quarkus.opentelemetry.runtime.config.runtime.exporter.OtlpExporterRuntimeConfig; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
class OpenTelemetryLegacyConfigurationTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.overrideConfigKey("quarkus.opentelemetry.enabled", "false") | ||
.overrideConfigKey("quarkus.opentelemetry.tracer.enabled", "false") | ||
.overrideConfigKey("quarkus.opentelemetry.tracer.suppress-non-application-uris", "false") | ||
.overrideConfigKey("quarkus.opentelemetry.tracer.include-static-resources", "true") | ||
.overrideConfigKey("quarkus.opentelemetry.tracer.sampler", "off") | ||
.overrideConfigKey("quarkus.opentelemetry.tracer.sampler.ratio", "2.0d") | ||
.overrideConfigKey("quarkus.opentelemetry.tracer.exporter.otlp.headers", "header=value") | ||
.overrideConfigKey("quarkus.opentelemetry.tracer.exporter.otlp.enabled", "false") | ||
.overrideConfigKey("quarkus.opentelemetry.tracer.exporter.otlp.endpoint", "http://localhost:4318/"); | ||
|
||
@Inject | ||
OTelBuildConfig oTelBuildConfig; | ||
@Inject | ||
OTelRuntimeConfig oTelRuntimeConfig; | ||
@Inject | ||
OtlpExporterBuildConfig otlpExporterBuildConfig; | ||
@Inject | ||
OtlpExporterRuntimeConfig otlpExporterRuntimeConfig; | ||
|
||
@Test | ||
void config() { | ||
assertEquals(FALSE, oTelBuildConfig.enabled()); | ||
assertTrue(oTelBuildConfig.traces().enabled().isPresent()); | ||
assertEquals(FALSE, oTelBuildConfig.traces().enabled().get()); | ||
assertEquals(FALSE, oTelRuntimeConfig.traces().suppressNonApplicationUris()); | ||
assertEquals(TRUE, oTelRuntimeConfig.traces().includeStaticResources()); | ||
assertEquals("always_off", oTelBuildConfig.traces().sampler()); | ||
assertTrue(oTelRuntimeConfig.traces().samplerArg().isPresent()); | ||
assertEquals(2.0d, oTelRuntimeConfig.traces().samplerArg().get()); | ||
assertEquals(FALSE, otlpExporterBuildConfig.enabled()); | ||
assertTrue(otlpExporterRuntimeConfig.traces().legacyEndpoint().isPresent()); | ||
assertTrue(otlpExporterRuntimeConfig.traces().headers().isPresent()); | ||
assertEquals("header=value", otlpExporterRuntimeConfig.traces().headers().get().get(0)); | ||
assertEquals("http://localhost:4318/", otlpExporterRuntimeConfig.traces().legacyEndpoint().get()); | ||
} | ||
} |
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.