Skip to content

Commit

Permalink
Merge pull request #39174 from radcortez/quarkus-36836
Browse files Browse the repository at this point in the history
Enable MP Telemetry TCK
  • Loading branch information
radcortez authored Mar 5, 2024
2 parents c35fda5 + d27577a commit 6583921
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 15 deletions.
8 changes: 6 additions & 2 deletions tcks/microprofile-opentelemetry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- TODO - Because of PropagatorSpiTest, which contains multiple Application classes - needs to be fixed in the TCK -->
<systemPropertyVariables>
<quarkus.resteasy.ignore-application-classes>true</quarkus.resteasy.ignore-application-classes>
</systemPropertyVariables>
<dependenciesToScan>
<!-- brunobat: Otel 1.23.x breaks the current version of the MP TCK -->
<!-- <dependency>org.eclipse.microprofile.telemetry.tracing:microprofile-telemetry-tracing-tck</dependency>-->
<dependency>org.eclipse.microprofile.telemetry.tracing:microprofile-telemetry-tracing-tck</dependency>
</dependenciesToScan>
<excludesFile>src/test/resources/exclusions.txt</excludesFile>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.quarkus.tck.opentelemetry;

import java.util.function.Function;

import io.smallrye.config.RelocateConfigSourceInterceptor;

/**
* MicroProfile Telemetry must read <code>otel.*</code>
* <a href=
* "https://github.com/eclipse/microprofile-telemetry/blob/1.1/tracing/spec/src/main/asciidoc/microprofile-telemetry-tracing-spec.asciidoc#configuration">properties</a>.
* <br>
* Quarkus only reads <code>quarkus.otel.*</code> properties to be consistent with Quarkus configuration model. This
* interceptor relocates the Quarkus OpenTelemetry configuration in the standard OpenTelemetry configuration.
*/
public class TelemetryRelocateInterceptor extends RelocateConfigSourceInterceptor {
public TelemetryRelocateInterceptor() {
super(new Function<String, String>() {
@Override
public String apply(final String name) {
if (name.startsWith("quarkus.otel.")) {
return name.substring(8);
} else if (name.startsWith("otel.")) {
return "quarkus." + name;
}
return name;
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;

import io.smallrye.config.ConfigSourceInterceptor;

public class DeploymentProcessor implements ApplicationArchiveProcessor {
@Override
public void process(Archive<?> archive, TestClass testClass) {
if (archive instanceof WebArchive) {
WebArchive war = (WebArchive) archive;
war.addClass(TelemetryRelocateInterceptor.class);
war.addAsServiceProvider(ConfigSourceInterceptor.class, TelemetryRelocateInterceptor.class);

boolean otelSdkDisabled = true;
Node microprofileConfig = war.get("/WEB-INF/classes/META-INF/microprofile-config.properties");
Expand All @@ -31,10 +35,8 @@ public void process(Archive<?> archive, TestClass testClass) {
}
}

// Remap OTel config to Quarkus config. Remove this after OTel Config integration is complete https://github.com/quarkusio/quarkus/pull/30033
war.addAsResource(new StringAsset(
"quarkus.opentelemetry.tracer.sampler=" + (otelSdkDisabled ? "off" : "on") + "\n" +
"quarkus.opentelemetry.tracer.resource-attributes=service.name=${otel.service.name:quarkus-tck-microprofile-opentelemetry},${otel.resource.attributes:}\n"),
"quarkus.otel.sdk.disabled=" + (otelSdkDisabled ? "true" : "false") + "\n"),
"application.properties");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.Application;
import jakarta.ws.rs.core.Response;

import org.jboss.arquillian.container.test.api.Deployment;
Expand All @@ -26,8 +24,6 @@
public class TestApplication extends Arquillian {
@ArquillianResource
URL url;
@Inject
HelloBean helloBean;

@Deployment
public static WebArchive createDeployment() {
Expand All @@ -42,12 +38,7 @@ public void rest() {
assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
}

@ApplicationPath("/rest")
public static class RestApplication extends Application {

}

@Path("/")
@Path("/rest")
public static class TestEndpoint {
@Inject
HelloBean helloBean;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Optional tests
org.eclipse.microprofile.telemetry.tracing.tck.rest.JaegerPropagationTest
org.eclipse.microprofile.telemetry.tracing.tck.rest.B3MultiPropagationTest
org.eclipse.microprofile.telemetry.tracing.tck.rest.B3PropagationTest
org.eclipse.microprofile.telemetry.tracing.tck.async.JaxRsServerAsyncTest

0 comments on commit 6583921

Please sign in to comment.