-
Notifications
You must be signed in to change notification settings - Fork 3k
Ensure gRPC server starts after Otel is configured (if applicable) #47076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,140 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <groupId>io.quarkus</groupId> | ||
| <artifactId>quarkus-integration-tests-parent</artifactId> | ||
| <version>999-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>quarkus-integration-test-opentelemetry-grpc-only</artifactId> | ||
| <name>Quarkus - Integration Tests - OpenTelemetry gRPC Only</name> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>io.quarkus</groupId> | ||
| <artifactId>quarkus-grpc</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.quarkus</groupId> | ||
| <artifactId>quarkus-opentelemetry</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.quarkus</groupId> | ||
| <artifactId>quarkus-arc</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.quarkus</groupId> | ||
| <artifactId>quarkus-junit5</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <!-- Minimal test dependencies to *-deployment artifacts for consistent build order --> | ||
| <dependency> | ||
| <groupId>io.quarkus</groupId> | ||
| <artifactId>quarkus-grpc-deployment</artifactId> | ||
| <version>${project.version}</version> | ||
| <type>pom</type> | ||
| <scope>test</scope> | ||
| <exclusions> | ||
| <exclusion> | ||
| <groupId>*</groupId> | ||
| <artifactId>*</artifactId> | ||
| </exclusion> | ||
| </exclusions> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.quarkus</groupId> | ||
| <artifactId>quarkus-opentelemetry-deployment</artifactId> | ||
| <version>${project.version}</version> | ||
| <type>pom</type> | ||
| <scope>test</scope> | ||
| <exclusions> | ||
| <exclusion> | ||
| <groupId>*</groupId> | ||
| <artifactId>*</artifactId> | ||
| </exclusion> | ||
| </exclusions> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.quarkus</groupId> | ||
| <artifactId>quarkus-arc-deployment</artifactId> | ||
| <version>${project.version}</version> | ||
| <type>pom</type> | ||
| <scope>test</scope> | ||
| <exclusions> | ||
| <exclusion> | ||
| <groupId>*</groupId> | ||
| <artifactId>*</artifactId> | ||
| </exclusion> | ||
| </exclusions> | ||
| </dependency> | ||
|
|
||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>io.quarkus</groupId> | ||
| <artifactId>quarkus-maven-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <goals> | ||
| <goal>build</goal> | ||
| <goal>generate-code</goal> | ||
| <goal>generate-code-tests</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
|
|
||
| <profiles> | ||
| <profile> | ||
| <id>native-image</id> | ||
| <activation> | ||
| <property> | ||
| <name>native</name> | ||
| </property> | ||
| </activation> | ||
|
|
||
| <properties> | ||
| <quarkus.native.enabled>true</quarkus.native.enabled> | ||
| </properties> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
| <configuration> | ||
| <skipTests>${native.surefire.skip}</skipTests> | ||
| </configuration> | ||
| </plugin> | ||
|
|
||
| <plugin> | ||
| <artifactId>maven-failsafe-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <goals> | ||
| <goal>integration-test</goal> | ||
| <goal>verify</goal> | ||
| </goals> | ||
| <configuration> | ||
| <systemPropertyVariables> | ||
| <native.image.path> | ||
| ${project.build.directory}/${project.build.finalName}-runner | ||
| </native.image.path> | ||
| </systemPropertyVariables> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </profile> | ||
| </profiles> | ||
| </project> |
26 changes: 26 additions & 0 deletions
26
...ntelemetry-grpc-only/src/main/java/io/quarkus/it/opentelemetry/grpc/HelloGrpcService.java
This file contains hidden or 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,26 @@ | ||
| package org.acme; | ||
|
|
||
| import io.opentelemetry.api.metrics.LongCounter; | ||
| import io.opentelemetry.api.metrics.Meter; | ||
| import io.quarkus.grpc.GrpcService; | ||
| import io.smallrye.mutiny.Uni; | ||
|
|
||
| @GrpcService | ||
| public class HelloGrpcService implements HelloGrpc { | ||
| private final LongCounter counter; | ||
|
|
||
| public HelloGrpcService(Meter meter) { | ||
| counter = meter.counterBuilder("hello-metrics") | ||
| .setDescription("hello-metrics") | ||
| .setUnit("invocations") | ||
| .build(); | ||
| } | ||
|
|
||
| @Override | ||
| public Uni<HelloReply> sayHello(HelloRequest request) { | ||
| counter.add(1); | ||
|
|
||
| return Uni.createFrom().item("Hello " + request.getName() + "!") | ||
| .map(msg -> HelloReply.newBuilder().setMessage(msg).build()); | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
integration-tests/opentelemetry-grpc-only/src/main/proto/hello.proto
This file contains hidden or 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 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| option java_multiple_files = true; | ||
| option java_package = "org.acme"; | ||
| option java_outer_classname = "HelloGrpcProto"; | ||
|
|
||
| package hello; | ||
|
|
||
| service HelloGrpc { | ||
| rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
| } | ||
|
|
||
| message HelloRequest { | ||
| string name = 1; | ||
| } | ||
|
|
||
| message HelloReply { | ||
| string message = 1; | ||
| } |
10 changes: 10 additions & 0 deletions
10
integration-tests/opentelemetry-grpc-only/src/main/resources/application.properties
This file contains hidden or 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,10 @@ | ||
| quarkus.grpc.clients.hello.host=localhost | ||
| %test.quarkus.grpc.clients.hello.port=9001 | ||
|
|
||
| quarkus.otel.bsp.schedule.delay=100 | ||
| quarkus.otel.bsp.export.timeout=5s | ||
|
|
||
| quarkus.otel.metrics.enabled=true | ||
|
|
||
| #quarkus.grpc.clients.streaming.use-quarkus-grpc-client=true | ||
| #quarkus.grpc.server.use-separate-server=false |
26 changes: 26 additions & 0 deletions
26
...lemetry-grpc-only/src/test/java/io/quarkus/it/opentelemetry/grpc/HelloGrpcClientTest.java
This file contains hidden or 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,26 @@ | ||
| package io.quarkus.it.opentelemetry.grpc; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import java.time.Duration; | ||
|
|
||
| import org.acme.HelloGrpc; | ||
| import org.acme.HelloReply; | ||
| import org.acme.HelloRequest; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import io.quarkus.grpc.GrpcClient; | ||
| import io.quarkus.test.junit.QuarkusTest; | ||
|
|
||
| @QuarkusTest | ||
| public class HelloGrpcClientTest { | ||
| @GrpcClient | ||
| HelloGrpc helloGrpc; | ||
|
|
||
| @Test | ||
| void testHello() { | ||
| HelloReply reply = helloGrpc | ||
| .sayHello(HelloRequest.newBuilder().setName("Neo").build()).await().atMost(Duration.ofSeconds(5)); | ||
| assertEquals("Hello Neo!", reply.getMessage()); | ||
| } | ||
| } |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about if we're more specific / exact, to "wait" for OTel, not an entire ArC?
e.g. to add some new build item, if needed ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried one of the BuildItem classes we already have in OTel and unfortunately it didn't work because although gRPC server started after OTel, the OTel bean is lazy and still caused the same problem