Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,9 @@ ServiceStartBuildItem initializeServer(GrpcServerRecorder recorder,
LaunchModeBuildItem launchModeBuildItem,
VertxWebRouterBuildItem routerBuildItem,
VertxBuildItem vertx, Capabilities capabilities,
List<FilterBuildItem> filterBuildItems) {
List<FilterBuildItem> filterBuildItems,
// used to ensure that gRPC server starts after OTel has been set up
@SuppressWarnings("unused") BeanContainerBuildItem beanContainerBuildItem) {
Copy link
Contributor

@alesj alesj Apr 1, 2025

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 ...

Copy link
Contributor Author

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


// Build the list of blocking methods per service implementation
Map<String, List<String>> blocking = new HashMap<>();
Expand Down
140 changes: 140 additions & 0 deletions integration-tests/opentelemetry-grpc-only/pom.xml
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>
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());
}
}
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;
}
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
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());
}
}
1 change: 1 addition & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@
<module>opentelemetry-vertx</module>
<module>opentelemetry-reactive</module>
<module>opentelemetry-grpc</module>
<module>opentelemetry-grpc-only</module>
<module>opentelemetry-vertx-exporter</module>
<module>opentelemetry-reactive-messaging</module>
<module>opentelemetry-redis-instrumentation</module>
Expand Down
Loading