Skip to content

Commit ddacac5

Browse files
authored
Merge pull request #2901 from newrelic/camel
Add additional coverage for Camel Async Processors
2 parents 5fb549c + d50e9e4 commit ddacac5

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# New Relic Instrumentation: Apache Camel 3.9.0+
2+
3+
Provides distributed tracing and transaction monitoring for applications using [Apache Camel](https://camel.apache.org/) 3.9.0 and above.
4+
5+
## What Is Instrumented
6+
7+
This module hooks into the Apache Camel lifecycle to create and propagate New Relic transactions across Camel routes.
8+
9+
## Configuration
10+
11+
One agent configuration value influences Kafka batch behaviour:
12+
13+
| Config Key | Default | Description |
14+
|---|---|-------------------------------------------------------------------------------------------------------|
15+
| `kafka.spans.distributed_trace.consume_many.enabled` | `false` | When `true`, distributed trace headers are accepted from the first exchange in a batch Kafka consume. |
16+
17+
## Notes
18+
19+
- Transactions will not start for certain routing steps (e.g. `direct:`, `seda:`) and/or logging to prevent noise in telemetry.

instrumentation/apache-camel-3.9.0/src/main/java/org/apache/camel/AsyncProcessor_Instrumentation.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,23 @@
1111
import com.newrelic.api.agent.weaver.MatchType;
1212
import com.newrelic.api.agent.weaver.Weave;
1313
import com.newrelic.api.agent.weaver.Weaver;
14+
import com.nr.instrumentation.apache.camel.CamelUtil;
15+
import com.nr.instrumentation.apache.camel.processors.ExchangeProcessor;
1416

1517
@Weave(originalName = "org.apache.camel.AsyncProcessor", type = MatchType.Interface)
1618
public class AsyncProcessor_Instrumentation {
1719

1820
@Trace(async = true, excludeFromTransactionTrace = true)
1921
public boolean process(Exchange exchange, AsyncCallback callback) {
2022
if (exchange instanceof Exchange_Instrumentation) {
21-
if (((Exchange_Instrumentation) exchange).token != null) {
22-
((Exchange_Instrumentation) exchange).token.link();
23+
Exchange_Instrumentation exchangeInstrumentation = (Exchange_Instrumentation) exchange;
24+
if (exchangeInstrumentation.token != null) {
25+
exchangeInstrumentation.token.link();
26+
} else if (exchangeInstrumentation.fromConsumer) {
27+
ExchangeProcessor exchangeProcessor = CamelUtil.getExchangeProcessor(CamelUtil.getEndpoint(exchange));
28+
if (exchangeProcessor != null && exchangeProcessor.shouldStartTransaction()) {
29+
CamelUtil.startTxn(exchange, exchangeProcessor);
30+
}
2331
}
2432
}
2533

instrumentation/apache-camel-3.9.0/src/main/java/org/apache/camel/Processor_Instrumentation.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ public void process(Exchange exchange) {
3030
}
3131
}
3232
}
33-
34-
3533
Weaver.callOriginal();
3634
}
3735
}

0 commit comments

Comments
 (0)