forked from quarkus-qe/beefy-scenarios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added opentracing, resteasy, mutiny example
- Loading branch information
Showing
20 changed files
with
528 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Module that test whether the opentracing data is transmitted among REST resources using Rest Client. | ||
There are two applications: | ||
- Ping application that will invoke the Pong application using the RestClient and will return the expected "ping pong" output. | ||
- Pong application that will return the "pong" output. |
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,67 @@ | ||
<?xml version="1.0"?> | ||
<project | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.quarkus.qe</groupId> | ||
<artifactId>beefy-scenarios</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>010-quarkus-opentracing-reactive-grpc</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-mutiny</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-smallrye-opentracing</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-rest-client</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-grpc</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>testcontainers</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.awaitility</groupId> | ||
<artifactId>awaitility</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>generate-code</goal> | ||
<goal>generate-code-tests</goal> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
28 changes: 28 additions & 0 deletions
28
010-quarkus-opentracing-reactive-grpc/src/main/java/io/quarkus/qe/ping/GrpcPingResource.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,28 @@ | ||
package io.quarkus.qe.ping; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import io.quarkus.example.PongRequest; | ||
import io.quarkus.example.PongServiceGrpc; | ||
import io.quarkus.grpc.runtime.annotations.GrpcService; | ||
import io.quarkus.qe.traceable.TraceableResource; | ||
|
||
@Path("/grpc-ping") | ||
public class GrpcPingResource extends TraceableResource { | ||
|
||
@Inject | ||
@GrpcService("pong") | ||
PongServiceGrpc.PongServiceBlockingStub pongClient; | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String getPing() { | ||
recordTraceId(); | ||
|
||
return "ping " + pongClient.sayPong(PongRequest.newBuilder().build()).getMessage(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
010-quarkus-opentracing-reactive-grpc/src/main/java/io/quarkus/qe/ping/PingResource.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,28 @@ | ||
package io.quarkus.qe.ping; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
|
||
import io.quarkus.qe.ping.clients.PongClient; | ||
import io.quarkus.qe.traceable.TraceableResource; | ||
|
||
@Path("/rest-ping") | ||
public class PingResource extends TraceableResource { | ||
|
||
@Inject | ||
@RestClient | ||
PongClient pongClient; | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String getPing() { | ||
recordTraceId(); | ||
|
||
return "ping " + pongClient.getPong(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...rkus-opentracing-reactive-grpc/src/main/java/io/quarkus/qe/ping/ReactivePingResource.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,30 @@ | ||
package io.quarkus.qe.ping; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
|
||
import io.quarkus.qe.ping.clients.ReactivePongClient; | ||
import io.quarkus.qe.traceable.TraceableResource; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@Path("/reactive-ping") | ||
public class ReactivePingResource extends TraceableResource { | ||
|
||
@Inject | ||
@RestClient | ||
ReactivePongClient pongClient; | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Uni<String> getPing() { | ||
recordTraceId(); | ||
return pongClient.getPong().onItem().transform(response -> { | ||
return "ping " + response; | ||
}); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...uarkus-opentracing-reactive-grpc/src/main/java/io/quarkus/qe/ping/clients/PongClient.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.qe.ping.clients; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
|
||
@RegisterRestClient | ||
public interface PongClient { | ||
@GET | ||
@Path("/rest-pong") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
String getPong(); | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...pentracing-reactive-grpc/src/main/java/io/quarkus/qe/ping/clients/ReactivePongClient.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,19 @@ | ||
package io.quarkus.qe.ping.clients; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
@RegisterRestClient | ||
public interface ReactivePongClient { | ||
@GET | ||
@Path("/reactive-pong") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
Uni<String> getPong(); | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
010-quarkus-opentracing-reactive-grpc/src/main/java/io/quarkus/qe/pong/GrpcPongService.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,27 @@ | ||
package io.quarkus.qe.pong; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import org.jboss.logmanager.MDC; | ||
|
||
import io.grpc.stub.StreamObserver; | ||
import io.quarkus.example.PongReply; | ||
import io.quarkus.example.PongRequest; | ||
import io.quarkus.example.PongServiceGrpc; | ||
|
||
@Singleton | ||
public class GrpcPongService extends PongServiceGrpc.PongServiceImplBase { | ||
|
||
private String lastTraceId; | ||
|
||
@Override | ||
public void sayPong(PongRequest request, StreamObserver<PongReply> responseObserver) { | ||
lastTraceId = MDC.get("traceId"); | ||
responseObserver.onNext(PongReply.newBuilder().setMessage("pong").build()); | ||
responseObserver.onCompleted(); | ||
} | ||
|
||
public String getLastTraceId() { | ||
return lastTraceId; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
010-quarkus-opentracing-reactive-grpc/src/main/java/io/quarkus/qe/pong/PongResource.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,19 @@ | ||
package io.quarkus.qe.pong; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import io.quarkus.qe.traceable.TraceableResource; | ||
|
||
@Path("/rest-pong") | ||
public class PongResource extends TraceableResource { | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String getPong() { | ||
recordTraceId(); | ||
return "pong"; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...rkus-opentracing-reactive-grpc/src/main/java/io/quarkus/qe/pong/ReactivePongResource.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,20 @@ | ||
package io.quarkus.qe.pong; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import io.quarkus.qe.traceable.TraceableResource; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@Path("/reactive-pong") | ||
public class ReactivePongResource extends TraceableResource { | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Uni<String> getPong() { | ||
recordTraceId(); | ||
return Uni.createFrom().item("pong"); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...us-opentracing-reactive-grpc/src/main/java/io/quarkus/qe/traceable/TraceableResource.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,28 @@ | ||
package io.quarkus.qe.traceable; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.jboss.logging.Logger; | ||
import org.jboss.logmanager.MDC; | ||
|
||
public abstract class TraceableResource { | ||
|
||
private static final Logger LOG = Logger.getLogger(TraceableResource.class); | ||
|
||
private String lastTraceId; | ||
|
||
@GET | ||
@Path("/lastTraceId") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String getLastTraceId() { | ||
return lastTraceId; | ||
} | ||
|
||
protected void recordTraceId() { | ||
lastTraceId = MDC.get("traceId"); | ||
LOG.info("Recorded trace ID: " + lastTraceId); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
010-quarkus-opentracing-reactive-grpc/src/main/proto/pong.proto
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,18 @@ | ||
syntax = "proto3"; | ||
|
||
option java_multiple_files = true; | ||
option java_package = "io.quarkus.example"; | ||
option java_outer_classname = "PongProto"; | ||
|
||
package io.quarkus.example; | ||
|
||
service PongService { | ||
rpc SayPong (PongRequest) returns (PongReply) {} | ||
} | ||
|
||
message PongRequest { | ||
} | ||
|
||
message PongReply { | ||
string message = 1; | ||
} |
18 changes: 18 additions & 0 deletions
18
010-quarkus-opentracing-reactive-grpc/src/main/resources/application.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Quarkus | ||
quarkus.http.port=8081 | ||
|
||
# Jaeger | ||
quarkus.jaeger.service-name=pingpong | ||
quarkus.jaeger.sampler-type=const | ||
quarkus.jaeger.sampler-param=1 | ||
quarkus.log.console.format=%d{HH:mm:ss} %-5p traceId=%X{traceId}, parentId=%X{parentId}, spanId=%X{spanId}, sampled=%X{sampled} [%c{2.}] (%t) %s%e%n | ||
|
||
# RestClient | ||
io.quarkus.qe.ping.clients.PongClient/mp-rest/url=http://localhost:8081 | ||
io.quarkus.qe.ping.clients.PongClient/mp-rest/scope=javax.inject.Singleton | ||
|
||
io.quarkus.qe.ping.clients.ReactivePongClient/mp-rest/url=http://localhost:8081 | ||
io.quarkus.qe.ping.clients.ReactivePongClient/mp-rest/scope=javax.inject.Singleton | ||
|
||
# gRPC | ||
quarkus.grpc.clients.pong.host=localhost |
Oops, something went wrong.