Skip to content

Commit

Permalink
Merge pull request #1270 from quarkiverse/opentelemetry-tests
Browse files Browse the repository at this point in the history
Move OpenTelemetry tests to dedicated module
  • Loading branch information
geoand authored Feb 7, 2025
2 parents 574cbaa + c2775db commit 2fec33c
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 37 deletions.
15 changes: 0 additions & 15 deletions core/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,6 @@
<artifactId>quarkus-test-vertx</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-mockito</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkiverse.langchain4j.test.listeners;
package io.quarkiverse.langchain4j.test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
71 changes: 71 additions & 0 deletions core/opentelemetry-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?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.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-core-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-langchain4j-core-opentelemetry-tests</artifactId>
<version>999-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-core-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-mockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkiverse.langchain4j.test.listeners;
package io.quarkiverse.langchain4j.opentelemetry.test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package io.quarkiverse.langchain4j.test.listeners;
package io.quarkiverse.langchain4j.opentelemetry.test;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.maven.dependency.Dependency;
import io.quarkus.test.QuarkusUnitTest;

class ListenersProcessorOnlySpanChatModelListenerTest
extends ListenersProcessorAbstractSpanChatModelListenerTest {
@RegisterExtension
static final QuarkusUnitTest unitTest = new QuarkusUnitTest()
.setArchiveProducer(
ListenersProcessorAbstractSpanChatModelListenerTest::appWithInMemorySpanExporter)
.setForcedDependencies(
List.of(Dependency.of("io.quarkus", "quarkus-opentelemetry", "3.15.2")));
ListenersProcessorAbstractSpanChatModelListenerTest::appWithInMemorySpanExporter);

@Test
void shouldHaveSpanChatModelListenerWithoutContributors() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package io.quarkiverse.langchain4j.test.listeners;
package io.quarkiverse.langchain4j.opentelemetry.test;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;

import jakarta.enterprise.context.ApplicationScoped;

import org.junit.jupiter.api.Test;
Expand All @@ -16,17 +14,14 @@
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.quarkiverse.langchain4j.runtime.listeners.ChatModelSpanContributor;
import io.quarkus.maven.dependency.Dependency;
import io.quarkus.test.QuarkusUnitTest;

class ListenersProcessorSingleChatModelSpanContributorTest
extends ListenersProcessorAbstractSpanChatModelListenerTest {
@RegisterExtension
static final QuarkusUnitTest unitTest = new QuarkusUnitTest()
.setArchiveProducer(
() -> appWithInMemorySpanExporter().addClasses(TestChatModelSpanContributor.class))
.setForcedDependencies(
List.of(Dependency.of("io.quarkus", "quarkus-opentelemetry", "3.15.2")));
() -> appWithInMemorySpanExporter().addClasses(TestChatModelSpanContributor.class));

@Test
void shouldHaveSpanChatModelListenerWitContributor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkiverse.langchain4j.test.listeners;
package io.quarkiverse.langchain4j.opentelemetry.test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
Expand All @@ -9,7 +9,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;

import java.util.List;
import java.util.function.BiConsumer;

import jakarta.enterprise.context.ApplicationScoped;
Expand All @@ -25,7 +24,6 @@
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.internal.data.ExceptionEventData;
import io.quarkiverse.langchain4j.runtime.listeners.ChatModelSpanContributor;
import io.quarkus.maven.dependency.Dependency;
import io.quarkus.test.QuarkusUnitTest;

class ListenersProcessorTwoChatModelSpanContributorsTest
Expand All @@ -36,9 +34,7 @@ class ListenersProcessorTwoChatModelSpanContributorsTest
() -> appWithInMemorySpanExporter()
.addClasses(
FirstChatModelSpanContributor.class,
SecondChatModelSpanContributor.class))
.setForcedDependencies(
List.of(Dependency.of("io.quarkus", "quarkus-opentelemetry", "3.15.2")));
SecondChatModelSpanContributor.class));

static BiConsumer<ChatModelRequestContext, Span> onRequest;
static BiConsumer<ChatModelResponseContext, Span> onResponse;
Expand Down
1 change: 1 addition & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<module>deployment</module>
<module>runtime</module>
<module>runtime-spi</module>
<module>opentelemetry-tests</module>
</modules>

</project>

0 comments on commit 2fec33c

Please sign in to comment.