-
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.
- Loading branch information
1 parent
f762885
commit fea9a08
Showing
17 changed files
with
400 additions
and
3 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
5 changes: 3 additions & 2 deletions
5
extensions/micrometer/deployment/src/test/resources/test-logging.properties
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#quarkus.log.category."io.quarkus.micrometer".level=DEBUG | ||
quarkus.log.category."io.quarkus.micrometer".level=DEBUG | ||
quarkus.log.category."io.quarkus.resteasy.observability".level=DEBUG | ||
quarkus.log.category."io.quarkus.bootstrap".level=INFO | ||
#quarkus.log.category."io.quarkus.arc".level=DEBUG | ||
quarkus.log.category."io.quarkus.arc".level=DEBUG | ||
quarkus.log.category."io.netty".level=INFO |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-observability-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>quarkus-resteasy-observability-deployment</artifactId> | ||
<name>Quarkus - RESTEasy Observability - Deployment</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-core-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-arc-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-observability</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-observability-spi</artifactId> | ||
</dependency> | ||
|
||
<!-- test --> | ||
|
||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5-internal</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<quarkus.log.level>INFO</quarkus.log.level> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-processor</artifactId> | ||
<version>${project.version}</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
100 changes: 100 additions & 0 deletions
100
...ava/io/quarkus/resteasy/observability/runtime/deployment/RestPathAnnotationProcessor.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,100 @@ | ||
package io.quarkus.resteasy.observability.runtime.deployment; | ||
|
||
import java.util.Optional; | ||
import java.util.regex.Pattern; | ||
|
||
import org.jboss.jandex.AnnotationInstance; | ||
import org.jboss.jandex.AnnotationTarget; | ||
import org.jboss.jandex.AnnotationValue; | ||
import org.jboss.jandex.ClassInfo; | ||
import org.jboss.jandex.DotName; | ||
import org.jboss.jandex.MethodInfo; | ||
|
||
import io.quarkus.arc.deployment.AdditionalBeanBuildItem; | ||
import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem; | ||
import io.quarkus.arc.processor.AnnotationsTransformer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.resteasy.observability.runtime.QuarkusRestPathTemplate; | ||
import io.quarkus.resteasy.observability.runtime.QuarkusRestPathTemplateInterceptor; | ||
import io.quarkus.resteasy.observability.spi.RestApplicationPathBuildItem; | ||
|
||
public class RestPathAnnotationProcessor { | ||
|
||
static final DotName REST_PATH = DotName.createSimple("javax.ws.rs.Path"); | ||
static final DotName REGISTER_REST_CLIENT = DotName | ||
.createSimple("org.eclipse.microprofile.rest.client.inject.RegisterRestClient"); | ||
static final DotName TEMPLATE_PATH = DotName.createSimple(QuarkusRestPathTemplate.class.getName()); | ||
static final DotName TEMPLATE_PATH_INTERCEPTOR = DotName.createSimple(QuarkusRestPathTemplateInterceptor.class.getName()); | ||
|
||
public static final Pattern MULTIPLE_SLASH_PATTERN = Pattern.compile("//+"); | ||
|
||
@BuildStep() | ||
AdditionalBeanBuildItem registerBeanClasses() { | ||
return AdditionalBeanBuildItem.builder() | ||
.setUnremovable() | ||
.addBeanClass(TEMPLATE_PATH.toString()) | ||
.addBeanClass(TEMPLATE_PATH_INTERCEPTOR.toString()) | ||
.build(); | ||
} | ||
|
||
@BuildStep | ||
AnnotationsTransformerBuildItem findRestPaths( | ||
Optional<RestApplicationPathBuildItem> restApplicationPath) { | ||
|
||
return new AnnotationsTransformerBuildItem(new AnnotationsTransformer() { | ||
@Override | ||
public boolean appliesTo(AnnotationTarget.Kind kind) { | ||
return kind == AnnotationTarget.Kind.METHOD; | ||
} | ||
|
||
@Override | ||
public void transform(TransformationContext ctx) { | ||
AnnotationTarget target = ctx.getTarget(); | ||
MethodInfo methodInfo = target.asMethod(); | ||
ClassInfo classInfo = methodInfo.declaringClass(); | ||
|
||
AnnotationInstance annotation = methodInfo.annotation(REST_PATH); | ||
if (annotation == null) { | ||
return; | ||
} | ||
StringBuilder stringBuilder = new StringBuilder(slashify(annotation.value().asString())); | ||
|
||
// Look for @Path annotation on the class | ||
annotation = classInfo.classAnnotation(REST_PATH); | ||
if (annotation != null) { | ||
stringBuilder.insert(0, slashify(annotation.value().asString())); | ||
} | ||
|
||
// Add the @ApplicationPath (unless RestClient) | ||
if (restApplicationPath.isPresent() && classInfo.classAnnotation(REGISTER_REST_CLIENT) == null) { | ||
stringBuilder.insert(0, slashify(restApplicationPath.get().getApplicationPath())); | ||
} | ||
|
||
// Now make sure there is a leading path, and no duplicates | ||
String templatePath = MULTIPLE_SLASH_PATTERN.matcher('/' + stringBuilder.toString()).replaceAll("/"); | ||
|
||
// resulting path (used as observability tags) should start with a '/' | ||
ctx.transform() | ||
.add(TEMPLATE_PATH, AnnotationValue.createStringValue("value", templatePath)) | ||
.done(); | ||
} | ||
}); | ||
} | ||
|
||
String slashify(String path) { | ||
// avoid doubles later. Empty for now | ||
if (path == null || path.isEmpty() || "/".equals(path)) { | ||
return ""; | ||
} | ||
// remove doubles | ||
path = MULTIPLE_SLASH_PATTERN.matcher(path).replaceAll("/"); | ||
// Label value consistency: result should not end with a slash | ||
if (path.endsWith("/")) { | ||
path = path.substring(0, path.length() - 1); | ||
} | ||
if (path.isEmpty() || path.startsWith("/")) { | ||
return path; | ||
} | ||
return '/' + path; | ||
} | ||
} |
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,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>quarkus-extensions-parent</artifactId> | ||
<groupId>io.quarkus</groupId> | ||
<version>999-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<!-- This extension works with BOTH resteasy-classic AND resteasy-reactive extensions --> | ||
<artifactId>quarkus-resteasy-observability-parent</artifactId> | ||
<name>Quarkus - RESTEasy Observability</name> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>spi</module> | ||
<module>runtime</module> | ||
<module>deployment</module> | ||
</modules> | ||
</project> |
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,51 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-observability-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>quarkus-resteasy-observability</artifactId> | ||
<name>Quarkus - RESTEasy Observability - Runtime</name> | ||
<description>Telemetry for RESTEasy workloads</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-core</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-arc</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-bootstrap-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-processor</artifactId> | ||
<version>${project.version}</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
17 changes: 17 additions & 0 deletions
17
...time/src/main/java/io/quarkus/resteasy/observability/runtime/QuarkusRestPathTemplate.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,17 @@ | ||
package io.quarkus.resteasy.observability.runtime; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import javax.interceptor.InterceptorBinding; | ||
|
||
@Inherited | ||
@InterceptorBinding | ||
@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface QuarkusRestPathTemplate { | ||
String value() default ""; | ||
} |
Oops, something went wrong.