generated from newrelic-experimental/java-instrumentation-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
110 changed files
with
584 additions
and
4,063 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
camel-core-3.18/src/main/java/org/apache/camel/support/DefaultProducer.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 3 additions & 21 deletions
24
....0/src/main/java/com/nr/instrumentation/apache/camel/ChoiceProcessor_instrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...l-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRAsyncProcessorStart.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.nr.instrumentation.apache.camel; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
import org.apache.camel.AsyncCallback; | ||
import org.apache.camel.AsyncProcessor; | ||
import org.apache.camel.Exchange; | ||
|
||
import com.newrelic.agent.bridge.AgentBridge; | ||
import com.newrelic.api.agent.NewRelic; | ||
import com.newrelic.api.agent.Trace; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
|
||
public class NRAsyncProcessorStart implements AsyncProcessor { | ||
|
||
private static boolean isTransformed = false; | ||
|
||
private AsyncProcessor delegate = null; | ||
private String consumer = null; | ||
|
||
public NRAsyncProcessorStart(AsyncProcessor processor) { | ||
delegate = processor; | ||
if(!isTransformed) { | ||
AgentBridge.instrumentation.retransformUninstrumentedClass(getClass()); | ||
isTransformed = true; | ||
} | ||
} | ||
|
||
@Override | ||
@Trace(dispatcher = true) | ||
public void process(Exchange exchange) throws Exception { | ||
if(consumer != null) { | ||
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Camel","AsyncConsumerStart",consumer,"process-sync"); | ||
} | ||
Weaver.callOriginal(); | ||
} | ||
|
||
@Override | ||
@Trace(dispatcher = true) | ||
public boolean process(Exchange exchange, AsyncCallback callback) { | ||
if(consumer != null) { | ||
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Camel","AsyncConsumerStart",consumer,"process-async"); | ||
} | ||
return delegate.process(exchange, callback); | ||
} | ||
|
||
@Override | ||
@Trace(dispatcher = true) | ||
public CompletableFuture<Exchange> processAsync(Exchange exchange) { | ||
if(consumer != null) { | ||
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Camel","AsyncConsumerStart",consumer,"processAsync"); | ||
} | ||
return delegate.processAsync(exchange); | ||
} | ||
|
||
public void setConsumer(String s) { | ||
consumer = s; | ||
} | ||
} |
86 changes: 34 additions & 52 deletions
86
...core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRAsyncProcessorWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,58 @@ | ||
package com.nr.instrumentation.apache.camel; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import org.apache.camel.AsyncCallback; | ||
import org.apache.camel.AsyncProcessor; | ||
import org.apache.camel.Exchange; | ||
import org.apache.camel.Route; | ||
|
||
import com.newrelic.api.agent.NewRelic; | ||
import com.newrelic.agent.bridge.AgentBridge; | ||
import com.newrelic.api.agent.Token; | ||
import com.newrelic.api.agent.Trace; | ||
import com.newrelic.api.agent.TransactionNamePriority; | ||
import com.newrelic.api.agent.TransportType; | ||
|
||
public class NRAsyncProcessorWrapper extends NRProcessorWrapper implements AsyncProcessor { | ||
public class NRAsyncProcessorWrapper implements AsyncProcessor { | ||
|
||
public NRAsyncProcessorWrapper(AsyncProcessor p,Route r) { | ||
super(p,r); | ||
private AsyncProcessor delegate = null; | ||
protected Token token = null; | ||
protected static boolean isTransformed = false; | ||
|
||
|
||
public NRAsyncProcessorWrapper(AsyncProcessor d, Token t) { | ||
if(!isTransformed) { | ||
AgentBridge.instrumentation.retransformUninstrumentedClass(getClass()); | ||
isTransformed = true; | ||
} | ||
token = t; | ||
delegate = d; | ||
} | ||
|
||
@Override | ||
@Trace(dispatcher=true) | ||
@Trace(async = true) | ||
public boolean process(Exchange exchange, AsyncCallback callback) { | ||
Map<String, Object> attributes = new HashMap<String, Object>(); | ||
Util.recordExchange(attributes, exchange); | ||
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); | ||
NewRelic.getAgent().getTransaction().acceptDistributedTraceHeaders(TransportType.Other, new CamelHeaders(exchange)); | ||
String[] names; | ||
if(route != null) { | ||
String routeId = route.getId(); | ||
if(routeId != null && !routeId.isEmpty()) { | ||
names = new String[] {"Custom","AsyncProcessor",delegate.getClass().getSimpleName(),"process",routeId}; | ||
NewRelic.getAgent().getTracedMethod().addCustomAttribute("RouteId", routeId); | ||
NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, false, "Processor", "Process",routeId); | ||
} else { | ||
names = new String[] {"Custom","AsyncProcessor",delegate.getClass().getSimpleName(),"process"}; | ||
} | ||
} else { | ||
Object timerTaskValue = exchange.getProperty(Exchange.TIMER_NAME); | ||
if(timerTaskValue != null) { | ||
names = new String[] {"Custom","AsyncProcessor",delegate.getClass().getSimpleName(),"process","TimerTask",timerTaskValue.toString()}; | ||
} | ||
names = new String[] {"Custom","AsyncProcessor",delegate.getClass().getSimpleName(),"process"}; | ||
|
||
if(token != null) { | ||
token.linkAndExpire(); | ||
token = null; | ||
} | ||
NewRelic.getAgent().getTracedMethod().setMetricName(names); | ||
return ((AsyncProcessor)delegate).process(exchange, callback); | ||
return delegate.process(exchange,callback); | ||
} | ||
|
||
@Override | ||
@Trace(dispatcher = true) | ||
@Trace(async = true) | ||
public CompletableFuture<Exchange> processAsync(Exchange exchange) { | ||
Map<String, Object> attributes = new HashMap<String, Object>(); | ||
Util.recordExchange(attributes, exchange); | ||
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); | ||
NewRelic.getAgent().getTransaction().acceptDistributedTraceHeaders(TransportType.Other, new CamelHeaders(exchange)); | ||
String[] names; | ||
if(route != null) { | ||
String routeId = route.getId(); | ||
if(routeId != null && !routeId.isEmpty()) { | ||
names = new String[] {"Custom","AsyncProcessor",delegate.getClass().getSimpleName(),"process",routeId}; | ||
NewRelic.getAgent().getTracedMethod().addCustomAttribute("RouteId", routeId); | ||
} else { | ||
names = new String[] {"Custom","AsyncProcessor",delegate.getClass().getSimpleName(),"process"}; | ||
} | ||
} else { | ||
names = new String[] {"Custom","AsyncProcessor",delegate.getClass().getSimpleName(),"processAsync"}; | ||
|
||
if(token != null) { | ||
token.linkAndExpire(); | ||
token = null; | ||
} | ||
return delegate.processAsync(exchange); | ||
} | ||
|
||
@Trace(async = true) | ||
public void process(Exchange exchange) throws Exception { | ||
if(token != null) { | ||
token.linkAndExpire(); | ||
token = null; | ||
} | ||
NewRelic.getAgent().getTracedMethod().setMetricName(names); | ||
return ((AsyncProcessor)delegate).processAsync(exchange); | ||
delegate.process(exchange); | ||
} | ||
|
||
} |
Oops, something went wrong.