Skip to content

Commit

Permalink
Adding opentelementry
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaland committed Oct 26, 2024
1 parent 6a1d6f6 commit 81ce3b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-liquibase-mongodb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import dev.langchain4j.model.chat.StreamingChatLanguageModel;
import dev.langchain4j.rag.content.Content;
import dev.langchain4j.service.AiServices;
import io.opentelemetry.api.trace.Span;
import io.quarkus.runtime.util.StringUtil;
import io.smallrye.mutiny.Multi;
import jakarta.enterprise.context.ApplicationScoped;
Expand Down Expand Up @@ -66,7 +67,8 @@ public Multi<String> chat(AssistantChatRequest request) {

public Multi<String> chat(ChatBotRequest request) {

log.info("ChatBotService.chat: " + request);
String traceId = Span.current().getSpanContext().getTraceId();
log.info("ChatBotService.chat for message: " + request.getMessage() + " traceId: " + traceId);

validateRequest(request);

Expand All @@ -92,8 +94,10 @@ public Multi<String> chat(ChatBotRequest request) {
em.emit("\n\nSources used to generate this content:\n");
contentSources.forEach(content -> {
em.emit(content.textSegment().metadata().getString("source") + "\n");
log.info("Chat complete, traceId: " + traceId);
});
em.complete();})
em.complete();
})
.start();
});
return multi;
Expand Down

0 comments on commit 81ce3b9

Please sign in to comment.