davsclaus commented on code in PR #20529:
URL: https://github.com/apache/camel/pull/20529#discussion_r2636927174
##########
components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TraceProcessorsInterceptStrategy.java:
##########
@@ -42,13 +48,15 @@ public Processor wrapProcessorInInterceptors(
return new DelegateAsyncProcessor(new TraceProcessor(target,
processorDefinition));
}
- private class TraceProcessor implements Processor {
+ private class TraceProcessor implements AsyncProcessor {
Review Comment:
Is it not better to extend DefaultAsyncProcessor so it has lifecycle with
doStart/doStop etc
##########
components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TraceProcessorsInterceptStrategy.java:
##########
@@ -57,15 +65,48 @@ public void process(Exchange exchange) throws Exception {
if (tracer.isTraceProcessors() && !tracer.exclude(processor,
exchange.getContext())) {
tracer.beginProcessorSpan(exchange, processor);
try {
- target.process(exchange);
+ asyncProcessor.process(exchange);
} finally {
tracer.endProcessorSpan(exchange, processor);
}
} else {
// We must always execute this
- target.process(exchange);
+ asyncProcessor.process(exchange);
}
}
+
+ @Override
+ public boolean process(Exchange exchange, AsyncCallback callback) {
+ String processor = processorDefinition.getId() + "-" +
processorDefinition.getShortName();
+ if (tracer.isTraceProcessors() && !tracer.exclude(processor,
exchange.getContext())) {
Review Comment:
this if can be pre computed to a boolean so the duplicate code in the
finally below can just read the boolean value
##########
components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TraceProcessorsInterceptStrategy.java:
##########
@@ -57,15 +65,48 @@ public void process(Exchange exchange) throws Exception {
if (tracer.isTraceProcessors() && !tracer.exclude(processor,
exchange.getContext())) {
tracer.beginProcessorSpan(exchange, processor);
try {
- target.process(exchange);
+ asyncProcessor.process(exchange);
} finally {
tracer.endProcessorSpan(exchange, processor);
}
} else {
// We must always execute this
- target.process(exchange);
+ asyncProcessor.process(exchange);
}
}
+
+ @Override
+ public boolean process(Exchange exchange, AsyncCallback callback) {
+ String processor = processorDefinition.getId() + "-" +
processorDefinition.getShortName();
+ if (tracer.isTraceProcessors() && !tracer.exclude(processor,
exchange.getContext())) {
+ try {
+ tracer.beginProcessorSpan(exchange, processor);
+ } catch (Exception e) {
+ exchange.setException(e);
Review Comment:
if begin fails with exception should the tracer continue or should we break
out with callback.done(true); return true;
##########
components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TraceProcessorsInterceptStrategy.java:
##########
@@ -42,13 +48,15 @@ public Processor wrapProcessorInInterceptors(
return new DelegateAsyncProcessor(new TraceProcessor(target,
processorDefinition));
}
- private class TraceProcessor implements Processor {
+ private class TraceProcessor implements AsyncProcessor {
private final NamedNode processorDefinition;
- private final Processor target;
+ //private final Processor target;
Review Comment:
old code to remove
--
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]