Croway commented on PR #30291:
URL: https://github.com/apache/camel/pull/30291#issuecomment-6954749208

   Thanks for the review. I checked each point against the sources (Micrometer 
1.17.2, Spring AI 2.0.2, OpenTelemetry Java agent 2.33.1). Everything is 
addressed in 505f8cbaa3, except one nit where I'd keep the current behavior 
(explained below).
   
   ### Should fix
   1. **Spring AI with a meter-only registry.** Confirmed: 
`SimpleObservationRegistry.isNoop()` is only true without handlers. Camel now 
defers only when the registry has a Micrometer Tracing handler 
(`TracingObservationHandler`, also inside composite handlers, as Spring Boot 
groups them). `ObservationConfig.getObservationHandlers()` is package-private, 
so it is read by reflection; anything unreadable means "not traced", so Camel 
records the call. See `SpringAiTracingTest`.
   2. **Spring AI tool calls.** Confirmed: `OllamaChatModel` falls back to a 
static `ToolCallingManager` without a registry. The route tools are now 
deferred only when the registry of the model's own tool calling manager has a 
tracing handler. Static fields are skipped, because `DefaultToolCallingManager` 
and `OllamaChatModel` both declare static defaults of the looked-up types.
   3. **OpenTelemetry Java agent.** Confirmed: a renamed jar injected through 
`JAVA_TOOL_OPTIONS` was missed. Instead of a class probe, Camel now looks at 
the client: when the `openai-java` instrumentation is active, 
`OpenAIOkHttpClient.builder().build()` returns a JDK proxy whose handler is 
`io.opentelemetry.javaagent.shaded.instrumentation.openai.v1_1.InstrumentedOpenAiClient`.
 With the instrumentation off (system property, config file, SDK disabled, an 
agent without it), it is the plain `OpenAIClientImpl`. This settles both 
bullets: a renamed or operator-injected jar is caught, and nothing is skipped 
when the agent does not trace. It also covers the OpenTelemetry instrumentation 
library used directly. I checked it with the agent attached: one generation per 
call, where there were two.
   4. **Observation path at `detailed`.** Confirmed. The start attributes 
(provider, agent and tool names, tool call id, conversation id, 
`gen_ai.request.*`) are now added as high-cardinality values when the 
Observation stops; see 
`shouldRecordTheDetailedAttributesAsHighCardinalityValues`. For the custom 
agent, the path is now chosen before the run: an agent not built on 
`AbstractAgent` takes the `basic` path (one `gen_ai.client.operation`), and 
`recordOperationName` is gone from the API.
   5. **Precedence and wording.**
      - Confirmed that `MicrometerObservabilityTracer` is a camel-telemetry 
`Tracer`. The Observation path is now kept with that tracer; see 
`shouldKeepTheObservationPathWithTheMicrometerObservabilityTracer`. The upgrade 
guide now says the camel-opentelemetry2 path records the timer directly, 
without the `error` tag and the `.active` long task timer.
      - The metrics wording is fixed in `ai-observability.adoc`, the level 
javadoc and the Camel Main option (and its generated metadata): token totals 
are unchanged, model calls of an agent run are timed one by one at `detailed`, 
and the Observation path adds `camel.ai.agent` / `camel.ai.tool` timers.
      - The upgrade-guide note on deferral now says that at `basic` a 
`langchain4j-agent` run on a framework-traced model loses its run-level summary 
span.
   
   ### Nits
   - **CAMEL-27134 upgrade-guide entry:** removed; it will come with the 
camel-spring-boot change.
   - **`contentMaxLength`:** a value that is not positive now means the default 
(8192), documented.
   - **Surrogate pairs:** the cut backs off one char when it would split a pair.
   - **Tool arguments before filtering:** I would keep this one. 
`gen_ai.tool.call.arguments` is defined by the GenAI conventions as the 
arguments the model passed, and seeing the undeclared or `Camel*` names the 
model made up is what helps when debugging a tool call. The tool route's own 
spans show what the route received. The docs now say so.
   - **Finish reason:** the run now uses the same mapping as its model calls 
(`stop`, `tool_call`).
   - **`closeSpan`:** the span is pulled only when it is at the top of the 
exchange's stack.
   - **Test stand-ins:** the quarkus-langchain4j listener stand-in has the 
comment, and so do the two new stand-ins with real class names (the 
OpenTelemetry openai handler and `MicrometerObservabilityTracer`).
   
   On the camel-jbang monitor: thanks for taking it in CAMEL-27135.
   
   _Claude Code on behalf of Croway_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to