-
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
Showing
14 changed files
with
451 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
<?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-integration-tests-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>quarkus-integration-test-opentelemetry-quickstart</artifactId> | ||
<name>Quarkus - Integration Tests - OpenTelemetry quickstart</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-reactive-jackson</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-resteasy-reactive</artifactId> | ||
</dependency> | ||
|
||
|
||
<!-- Needed for InMemorySpanExporter to verify captured traces --> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk-testing</artifactId> | ||
</dependency> | ||
|
||
<!-- Test Dependencies --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.awaitility</groupId> | ||
<artifactId>awaitility</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Minimal test dependencies to *-deployment artifacts for consistent build order --> | ||
<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> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-reactive-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-resteasy-reactive-jackson-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> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<vertx.disableWebsockets>false</vertx.disableWebsockets> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>native-image</id> | ||
<activation> | ||
<property> | ||
<name>native</name> | ||
</property> | ||
</activation> | ||
|
||
<properties> | ||
<quarkus.package.type>native</quarkus.package.type> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skipTests>${native.surefire.skip}</skipTests> | ||
<systemPropertyVariables> | ||
<vertx.disableWebsockets>false</vertx.disableWebsockets> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<vertx.disableWebsockets>false</vertx.disableWebsockets> | ||
<native.image.path> | ||
${project.build.directory}/${project.build.finalName}-runner | ||
</native.image.path> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
46 changes: 46 additions & 0 deletions
46
.../opentelemetry-quickstart/src/main/java/io/quarkus/it/opentelemetry/ExporterResource.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,46 @@ | ||
package io.quarkus.it.opentelemetry; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.inject.Produces; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter; | ||
import io.opentelemetry.sdk.trace.data.SpanData; | ||
|
||
@Path("") | ||
public class ExporterResource { | ||
@Inject | ||
InMemorySpanExporter inMemorySpanExporter; | ||
|
||
@GET | ||
@Path("/reset") | ||
public Response reset() { | ||
inMemorySpanExporter.reset(); | ||
return Response.ok().build(); | ||
} | ||
|
||
@GET | ||
@Path("/export") | ||
public List<SpanData> export() { | ||
return inMemorySpanExporter.getFinishedSpanItems() | ||
.stream() | ||
.filter(sd -> !sd.getName().contains("export") && !sd.getName().contains("reset")) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
@ApplicationScoped | ||
static class InMemorySpanExporterProducer { | ||
@Produces | ||
@Singleton | ||
InMemorySpanExporter inMemorySpanExporter() { | ||
return InMemorySpanExporter.create(); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
.../opentelemetry-quickstart/src/main/java/io/quarkus/it/opentelemetry/GreetingResource.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,16 @@ | ||
package io.quarkus.it.opentelemetry; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
@Path("/hello") | ||
public class GreetingResource { | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String hello() { | ||
return "Hello from RESTEasy Reactive"; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...quickstart/src/main/java/io/quarkus/it/opentelemetry/output/SpanDataModuleSerializer.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.it.opentelemetry.output; | ||
|
||
import jakarta.inject.Singleton; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.module.SimpleModule; | ||
|
||
import io.opentelemetry.sdk.trace.data.SpanData; | ||
import io.quarkus.jackson.ObjectMapperCustomizer; | ||
|
||
@Singleton | ||
public class SpanDataModuleSerializer implements ObjectMapperCustomizer { | ||
@Override | ||
public void customize(ObjectMapper objectMapper) { | ||
SimpleModule simpleModule = new SimpleModule(); | ||
simpleModule.addSerializer(SpanData.class, new SpanDataSerializer()); | ||
objectMapper.registerModule(simpleModule); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...metry-quickstart/src/main/java/io/quarkus/it/opentelemetry/output/SpanDataSerializer.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,55 @@ | ||
package io.quarkus.it.opentelemetry.output; | ||
|
||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import com.fasterxml.jackson.databind.ser.std.StdSerializer; | ||
|
||
import io.opentelemetry.sdk.trace.data.SpanData; | ||
|
||
public class SpanDataSerializer extends StdSerializer<SpanData> { | ||
public SpanDataSerializer() { | ||
this(null); | ||
} | ||
|
||
public SpanDataSerializer(Class<SpanData> type) { | ||
super(type); | ||
} | ||
|
||
@Override | ||
public void serialize(SpanData spanData, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) | ||
throws IOException { | ||
jsonGenerator.writeStartObject(); | ||
|
||
jsonGenerator.writeStringField("spanId", spanData.getSpanId()); | ||
jsonGenerator.writeStringField("traceId", spanData.getTraceId()); | ||
jsonGenerator.writeStringField("name", spanData.getName()); | ||
jsonGenerator.writeStringField("kind", spanData.getKind().name()); | ||
jsonGenerator.writeBooleanField("ended", spanData.hasEnded()); | ||
|
||
jsonGenerator.writeStringField("parentSpanId", spanData.getParentSpanContext().getSpanId()); | ||
jsonGenerator.writeStringField("parent_spanId", spanData.getParentSpanContext().getSpanId()); | ||
jsonGenerator.writeStringField("parent_traceId", spanData.getParentSpanContext().getTraceId()); | ||
jsonGenerator.writeBooleanField("parent_remote", spanData.getParentSpanContext().isRemote()); | ||
jsonGenerator.writeBooleanField("parent_valid", spanData.getParentSpanContext().isValid()); | ||
|
||
spanData.getAttributes().forEach((k, v) -> { | ||
try { | ||
jsonGenerator.writeStringField("attr_" + k.getKey(), v.toString()); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
}); | ||
|
||
spanData.getResource().getAttributes().forEach((k, v) -> { | ||
try { | ||
jsonGenerator.writeStringField("resource_" + k.getKey(), v.toString()); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
}); | ||
|
||
jsonGenerator.writeEndObject(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
integration-tests/opentelemetry-quickstart/src/main/resources/META-INF/resources/test.html
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 @@ | ||
<html><body>Test</body></html> |
3 changes: 3 additions & 0 deletions
3
integration-tests/opentelemetry-quickstart/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,3 @@ | ||
# speed up build | ||
quarkus.otel.bsp.schedule.delay=0 | ||
quarkus.otel.bsp.export.timeout=5s |
20 changes: 20 additions & 0 deletions
20
...on-tests/opentelemetry-quickstart/src/test/java/io/quarkus/it/opentelemetry/BaseTest.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.it.opentelemetry; | ||
|
||
import static io.restassured.RestAssured.get; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import io.restassured.common.mapper.TypeRef; | ||
|
||
public class BaseTest { | ||
|
||
protected List<Map<String, Object>> getSpans() { | ||
return get("/export").body().as(new TypeRef<>() { | ||
}); | ||
} | ||
|
||
protected void buildGlobalTelemetryInstance() { | ||
// Do nothing in JVM mode | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...lemetry-quickstart/src/test/java/io/quarkus/it/opentelemetry/OpenTelemetryDisabledIT.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.it.opentelemetry; | ||
|
||
import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator; | ||
import io.opentelemetry.context.propagation.ContextPropagators; | ||
import io.opentelemetry.sdk.OpenTelemetrySdk; | ||
import io.opentelemetry.sdk.OpenTelemetrySdkBuilder; | ||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
|
||
@QuarkusIntegrationTest | ||
public class OpenTelemetryDisabledIT extends OpenTelemetryDisabledTest { | ||
@Override | ||
protected void buildGlobalTelemetryInstance() { | ||
// When running native tests the test class is outside the Quarkus application, | ||
// so we need to set the propagator on the GlobalOpenTelemetry instance | ||
OpenTelemetrySdkBuilder builder = OpenTelemetrySdk.builder(); | ||
builder.setPropagators(ContextPropagators.create(W3CTraceContextPropagator.getInstance())); | ||
builder.buildAndRegisterGlobal(); | ||
} | ||
} |
Oops, something went wrong.