Quarkus LangChain4j

Quarkus LangChain4j brings LangChain4j capabilities to the Quarkus framework, enabling AI development with native OpenTelemetry tracing for model interactions.

This guide covers routing telemetry from Quarkus LangChain4j applications to InteractiveAI using OpenTelemetry.

Prerequisites

  • InteractiveAI account with API credentials

  • Java 21+

  • OpenAI API key (or alternative model provider)


Step 1: Enable OpenTelemetry in Quarkus

Add the Quarkus OpenTelemetry dependency to your pom.xml:

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-opentelemetry</artifactId>
</dependency>

Configure the OpenTelemetry exporter protocol in application.properties:

quarkus.otel.exporter.otlp.traces.protocol=http/protobuf

With this configuration, Quarkus LangChain4j records internal calls (such as chat model invocations) as spans. Each span includes attributes like gen_ai.operation.name, gen_ai.system, model identifiers, and token usage.

To capture prompt and response content, enable LangChain4j tracing in application.properties:


Step 2: Configure InteractiveAI

Direct OpenTelemetry data to InteractiveAI by configuring the OTLP endpoint and authentication in application.properties:

See the OpenTelemetry integration page for details on Basic Auth configuration.


Step 3: Run an AI Operation

Start your Quarkus application and trigger an AI operation through a service that uses a ChatModel:


Running the Application

Configure environment variables:

Start the application:


Trace Visibility

The InteractiveAI dashboard displays:

  • Chat model invocations with prompts and completions

  • Token usage and model configuration

  • Tool calls and service interactions

  • Request latency and performance metrics

Last updated

Was this helpful?