Croway commented on issue #9518:
URL: https://github.com/apache/camel-quarkus/issues/9518#issuecomment-6961370671
Agreed, that's better than registering reflection in a camel-quarkus
extension: Camel Quarkus core already registers the services under
`META-INF/services/org/apache/camel/*`, so `ai-observation-factory` is picked
up as is, and the extension shrinks to the BOM, catalog and docs entries plus
its inclusion in observability-services.
One thing the POC changes: today `Method.invoke` wraps any error thrown by
the implementation, and the bridge catches `ReflectiveOperationException |
LinkageError`. The POC catches only `RuntimeException` in
`GenAiObservability.start`, so a `LinkageError` raised while the observation
starts now fails the LLM call, which the comment in `start` wants to avoid.
Reproduced with a handler that throws as one built against another Micrometer
version would:
```java
ObservationRegistry observationRegistry = ObservationRegistry.create();
observationRegistry.observationConfig().observationHandler(new
ObservationHandler<>() {
@Override
public void onStart(Observation.Context context) {
throw new NoSuchMethodError("'void
io.micrometer.observation.Observation$Context.example()'");
}
@Override
public boolean supportsContext(Observation.Context context) {
return true;
}
});
context.getRegistry().bind("observationRegistry", observationRegistry);
assertThatCode(() -> GenAiObservability.start(new DefaultExchange(context),
GenAiObservationContext.builder().operationName(GenAiOperationName.CHAT).requestModel("test-model").build()))
.doesNotThrowAnyException();
```
It passes on main (23590ac), fails on 050e062 with the `NoSuchMethodError`,
and passes with `catch (RuntimeException | LinkageError e)`; the other tests of
both modules pass with that change too.
Optional: the factory could be kept as a context plugin
(`ExtendedCamelContext#addContextPlugin`) rather than in a static map keyed by
`CamelContext`, so a stopped context is not kept reachable.
The POC touches the same two classes as apache/camel#30291 (CAMEL-27131).
Should it go in its own JIRA and PR? Whichever merges first, I can rebase the
other, and I'll rework the camel-quarkus extension on top of it.
_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]