AI / LangChain4j interview questions
How does LangChain4j integrate with observability tools like OpenTelemetry?
LangChain4j 0.31+ introduced native OpenTelemetry instrumentation for tracing LLM calls. When the langchain4j-open-telemetry module is on the classpath alongside an OTel SDK, LangChain4j automatically creates spans for each LLM call, embedding attributes from the OpenTelemetry Semantic Conventions for Generative AI Systems (draft spec).
Each span captures:
gen_ai.system— The LLM provider (e.g.,openai)gen_ai.request.model— The model name usedgen_ai.request.max_tokens— Max tokens configuredgen_ai.usage.input_tokens— Actual input tokens consumedgen_ai.usage.output_tokens— Actual output tokens generatedgen_ai.request.temperature— Temperature setting
For Spring Boot, adding the OTel Spring Boot starter alongside the LangChain4j OTel module is sufficient for automatic instrumentation:
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-open-telemetry</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-spring-boot-starter</artifactId>
</dependency>With these in place, every LLM call appears as a span in your Jaeger, Zipkin, Grafana Tempo, or any OTLP-compatible backend — showing latency distribution across providers and models, token usage trends, and which AI services are called in which order within a user request. This is critical for diagnosing slow AI paths in production without guessing.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
