[
https://issues.apache.org/jira/browse/CAMEL-23861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18104877#comment-18104877
]
Omar Atie commented on CAMEL-23861:
-----------------------------------
_AI-generated on behalf of atiaomar1978-hub_
Hi Claus,
Progress update on GenAI observability for Camel AI components. Work has been
delivered in three phases, aligned with your JIRA guidance (langchain4j +
OpenAI first, model headers, global toggle, OpenTelemetry spans then Micrometer
metrics).
h3. Overall status
|| Phase || PR || Status || Focus ||
| Phase 1 | [#25337|https://github.com/apache/camel/pull/25337] | *Merged*
(2026-08-13) | Core observability library + langchain4j + OpenAI |
| Phase 2 | [#25491|https://github.com/apache/camel/pull/25491] | *Merged*
(2026-08-14) | Camel TUI AI Usage view (route spans + CLI ask) |
| Phase 3 | [#25507|https://github.com/apache/camel/pull/25507] | *Open* (ready
for review) | Spring AI chat + Camel Main config
([CAMEL-24386|https://issues.apache.org/jira/browse/CAMEL-24386]) |
Phases 1 and 2 are on \{{main}} in 4.23. Phase 3 is implemented and under
review; once merged this ticket can be closed with \{{fixVersions = 4.23.0}}.
h3. What we achieved — mapped to the JIRA description
*OpenTelemetry GenAI semantic convention attributes* (when
\{{camel-opentelemetry2}} is active):
* \{{gen_ai.operation.name}} (e.g. \{{chat}}, \{{embeddings}})
* \{{gen_ai.system}} (e.g. \{{openai}}, \{{anthropic}}, \{{ollama}})
* \{{gen_ai.request.model}} / \{{gen_ai.response.model}}
* \{{gen_ai.usage.input_tokens}} / \{{gen_ai.usage.output_tokens}}
* \{{gen_ai.response.finish_reasons}}
* \{{camel.component}} (identifies the producing component)
*Micrometer metrics* (when \{{camel-micrometer}} is active):
* \{{gen_ai.client.operation}} — operation duration timer
* \{{gen_ai.client.token.usage}} — token counter with
\{{gen_ai.token.type=input|output}} tags
*Global toggle:*
* Property: \{{camel.ai.observability.enabled}} (default \{{true}}; no-op when
disabled or no backend on classpath)
* Camel Main (Phase 3):
\{{main.configure().ai().observability().withEnabled(false)}} and
\{{application.properties}} support via
\{{AiObservabilityConfigurationProperties}}
h3. Phase 1 — Core library and producer integration *(merged)*
*New modules:*
* \{{camel-ai-observability-api}} — lightweight API (\{{GenAiObservability}},
\{{GenAiObservation}}, \{{GenAiAttributes}}, \{{GenAiModelResolver}})
* \{{camel-ai-observability}} — implementation loaded reflectively; emits OTel
spans + Micrometer metrics via existing Camel telemetry services
*Components integrated:*
* \{{langchain4j-chat}} — per \{{chatModel.chat()}} call
* \{{langchain4j-tools}} — per tool-calling LLM iteration
* \{{langchain4j-agent}} — per agent invocation
* \{{langchain4j-embeddings}} — per embedding call
* \{{openai}} — chat completion and streaming paths
*Model identification exchange headers (langchain4j):*
* \{{CamelLangChain4jChatRequestModel}} / \{{CamelLangChain4jChatResponseModel}}
* \{{CamelLangChain4jToolsRequestModel}} /
\{{CamelLangChain4jToolsResponseModel}}
* \{{CamelLangChain4jAgentRequestModel}} /
\{{CamelLangChain4jAgentResponseModel}}
* \{{CamelLangChain4jEmbeddingsRequestModel}} /
\{{CamelLangChain4jEmbeddingsResponseModel}}
*Documentation:* \{{ai-observability.adoc}}, upgrade guide 4.23 entry
h3. Phase 2 — Camel TUI dashboard *(merged)*
Extends the TUI *AI Usage* panel (Ctrl+U) to visualize both:
* *TUI ask* token usage (from \{{camel ask}} / embedded AI prompt — builds on
[#24362|https://github.com/apache/camel/pull/24362])
* *Route* GenAI usage extracted from exported OTel spans via
\{{GenAiSpanUsageExtractor}}
Users see a combined dashboard in \{{camel tui}} with models labelled
\{{[tui]}} vs \{{[route:<routeId>]}}.
h3. Phase 3 — Spring AI + Camel Main *(open PR #25507)*
* \{{spring-ai-chat}} — \{{SpringAiChatProducer}} wraps normal chat, structured
output, and entity conversion paths with \{{GenAiObservability}}
* \{{GenAiModelResolver}} — reflection-based resolution for LangChain4j and
Spring AI (no compile-time SDK dependency in the API module)
* ChatClient-only routes — underlying \{{ChatModel}} cached/extracted at
startup for correct \{{gen_ai.system}} / \{{gen_ai.request.model}} metadata
* Entity path uses \{{responseEntity()}} so token usage and response model are
captured in spans
* Camel Main typed config for \{{camel.ai.observability.enabled}} (fixes
catalog metadata prefix; env/JVM property loading via \{{GROUP_PREFIXES}})
* Tests: \{{SpringAiChatObservabilityTest}} (ChatClient-only, entity, disabled
observability, token span tags),
\{{AiObservabilityConfigurationPropertiesTest}}, \{{GenAiModelResolverTest}}
h3. Remaining before closing this JIRA
# Merge [#25507|https://github.com/apache/camel/pull/25507] (Phase 3) once CI
is green and review is complete
# Set \{{fixVersions = 4.23.0}} and transition to Resolved/Fixed
# Link related [CAMEL-24386|https://issues.apache.org/jira/browse/CAMEL-24386]
(can be closed together with Phase 3 merge)
h3. Possible follow-ups (out of scope for current phases)
* Additional AI producers (e.g. other Spring AI modules beyond chat)
* Cost estimation dashboards / billing attributes
* Broader component coverage beyond langchain4j, OpenAI, and Spring AI chat
Happy to adjust scope or split follow-ups into separate tickets if you prefer.
Thanks,
Omar
> camel-langchain4j - Add OpenTelemetry and Micrometer observability for AI/LLM
> usage
> -----------------------------------------------------------------------------------
>
> Key: CAMEL-23861
> URL: https://issues.apache.org/jira/browse/CAMEL-23861
> Project: Camel
> Issue Type: Improvement
> Components: camel-langchain4j-agent, camel-langchain4j-chat,
> camel-langchain4j-embeddings, camel-langchain4j-tools
> Reporter: Claus Ibsen
> Assignee: Omar Atie
> Priority: Major
> Labels: ai, observability
> Fix For: 4.23.0
>
>
> The camel-langchain4j components currently have no observability integration
> for AI/LLM-specific metrics and tracing. Token usage, model name, finish
> reason, and latency are not captured.
> Spring AI exposes this data through the Micrometer Observation API (which
> produces both metrics and traces) following the OpenTelemetry Semantic
> Conventions for GenAI (https://opentelemetry.io/docs/specs/semconv/gen-ai/).
> This enables dashboards showing token consumption, costs, model distribution,
> and conversation tracking.
> Camel should follow the same approach. When camel-micrometer or
> camel-opentelemetry2 is active, the langchain4j producers should capture:
> *OpenTelemetry span attributes (GenAI semantic conventions):*
> - gen_ai.system (e.g. openai, anthropic)
> - gen_ai.request.model
> - gen_ai.response.model
> - gen_ai.usage.input_tokens
> - gen_ai.usage.output_tokens
> - gen_ai.response.finish_reasons
> *Micrometer metrics:*
> - Token counters (input/output/total) with model tag
> - Request counters per model/operation
> - Latency timers/histograms
> - Error counters
> This would allow standard observability tooling (Grafana, Jaeger, Prometheus,
> etc.) and Camel TUI to visualize AI/LLM usage across routes.
> See also CAMEL-23860 which adds token data as exchange headers - this ticket
> is about propagating that data into the observability layer for monitoring
> and dashboards.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)