diff --git a/.gitignore b/.gitignore index 962f417..adaab9e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,3 @@ .project build bin -/.metadata/ diff --git a/build.gradle b/build.gradle index 13977ea..26dbd56 100644 --- a/build.gradle +++ b/build.gradle @@ -21,11 +21,11 @@ plugins { } project.ext { - group = 'com.newrelic.instrumentation.labs' + group = 'com.newrelic.instrumentation' javaAgentVersion = '6.4.1' // Aligned with minimum Java major version supported by latest Java Agent - javaVersion = JavaVersion.VERSION_17 + javaVersion = JavaVersion.VERSION_1_8 } @@ -76,7 +76,7 @@ task buildIfNeeded { task createModule { dependsOn checkForDependencies description = 'Generate project files for a new instrumentation module' - group = 'New Relic Labs' + group = 'New Relic' doLast { def rootProject = projectDir.path @@ -119,7 +119,7 @@ task createModule { // Example: // implementation 'javax.servlet:servlet-api:2.5' - // New Relic Labs Java Agent dependencies + // New Relic Java Agent dependencies implementation 'com.newrelic.agent.java:newrelic-agent:JAVA_AGENT_VERSION' implementation 'com.newrelic.agent.java:newrelic-api:JAVA_AGENT_VERSION' implementation fileTree(include: ['*.jar'], dir: '../libs') @@ -128,8 +128,8 @@ task createModule { jar { manifest { attributes 'Implementation-Title': 'PROJECT_GROUP.PROJECT_NAME' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' + attributes 'Implementation-Vendor': 'New Relic' + attributes 'Implementation-Vendor-Id': 'com.newrelic' attributes 'Implementation-Version': 1.0 } } @@ -174,7 +174,7 @@ subprojects { task install(dependsOn: buildIfNeeded, type: Copy) { description = 'Copies compiled jar to the NEW_RELIC_EXTENSIONS_DIR.' - group = 'New Relic Labs' + group = 'New Relic' def extDir = System.getenv("NEW_RELIC_EXTENSIONS_DIR") ?: " " diff --git a/camel-core-2.18/build.gradle b/camel-core-2.18/build.gradle index dbe5d7f..fde504e 100644 --- a/camel-core-2.18/build.gradle +++ b/camel-core-2.18/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'java' dependencies { implementation 'org.apache.camel:camel-core:3.18.0' - // New Relic Labs Java Agent dependencies + // New Relic Java Agent dependencies implementation 'com.newrelic.agent.java:newrelic-agent:6.0.0' implementation 'com.newrelic.agent.java:newrelic-api:6.0.0' implementation fileTree(include: ['*.jar'], dir: '../libs') @@ -14,9 +14,9 @@ dependencies { jar { manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.camel-core-3.18' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' + attributes 'Implementation-Title': 'com.newrelic.instrumentation.camel-core-3.18' + attributes 'Implementation-Vendor': 'New Relic' + attributes 'Implementation-Vendor-Id': 'com.newrelic' attributes 'Implementation-Version': 1.0 } } diff --git a/camel-core-2.20/build.gradle b/camel-core-2.20/build.gradle index 771196c..b7ba6d4 100644 --- a/camel-core-2.20/build.gradle +++ b/camel-core-2.20/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'java' dependencies { implementation 'org.apache.camel:camel-core:2.20.0' - // New Relic Labs Java Agent dependencies + // New Relic Java Agent dependencies implementation 'com.newrelic.agent.java:newrelic-agent:6.0.0' implementation 'com.newrelic.agent.java:newrelic-api:6.0.0' implementation fileTree(include: ['*.jar'], dir: '../libs') @@ -14,9 +14,9 @@ dependencies { jar { manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.camel-core-2.20' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' + attributes 'Implementation-Title': 'com.newrelic.instrumentation.camel-core-2.20' + attributes 'Implementation-Vendor': 'New Relic' + attributes 'Implementation-Vendor-Id': 'com.newrelic' attributes 'Implementation-Version': 1.0 } } diff --git a/camel-core-3.0/build.gradle b/camel-core-3.0/build.gradle index 7e730b3..1761a92 100644 --- a/camel-core-3.0/build.gradle +++ b/camel-core-3.0/build.gradle @@ -6,17 +6,17 @@ apply plugin: 'java' dependencies { implementation 'org.apache.camel:camel-core:3.0.0' - // New Relic Labs Java Agent dependencies - implementation 'com.newrelic.agent.java:newrelic-agent:7.4.0' - implementation 'com.newrelic.agent.java:newrelic-api:7.4.0' + // New Relic Java Agent dependencies + implementation 'com.newrelic.agent.java:newrelic-agent:6.4.0' + implementation 'com.newrelic.agent.java:newrelic-api:6.4.0' implementation fileTree(include: ['*.jar'], dir: '../libs') } jar { manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.camel-core-3.0' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' + attributes 'Implementation-Title': 'com.newrelic.instrumentation.camel-core-3.0' + attributes 'Implementation-Vendor': 'New Relic' + attributes 'Implementation-Vendor-Id': 'com.newrelic' attributes 'Implementation-Version': 1.0 } } diff --git a/camel-core-3.1/build.gradle b/camel-core-3.1/build.gradle index 1201f87..3fbb685 100644 --- a/camel-core-3.1/build.gradle +++ b/camel-core-3.1/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'java' dependencies { implementation 'org.apache.camel:camel-core:3.1.0' - // New Relic Labs Java Agent dependencies + // New Relic Java Agent dependencies implementation 'com.newrelic.agent.java:newrelic-agent:6.0.0' implementation 'com.newrelic.agent.java:newrelic-api:6.0.0' implementation fileTree(include: ['*.jar'], dir: '../libs') @@ -14,9 +14,9 @@ dependencies { jar { manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.camel-core-3.1' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' + attributes 'Implementation-Title': 'com.newrelic.instrumentation.camel-core-3.1' + attributes 'Implementation-Vendor': 'New Relic' + attributes 'Implementation-Vendor-Id': 'com.newrelic' attributes 'Implementation-Version': 1.0 } } diff --git a/camel-core-3.18/build.gradle b/camel-core-3.18/build.gradle index e397344..53e4589 100644 --- a/camel-core-3.18/build.gradle +++ b/camel-core-3.18/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'java' dependencies { implementation 'org.apache.camel:camel-core:3.18.0' - // New Relic Labs Java Agent dependencies + // New Relic Java Agent dependencies implementation 'com.newrelic.agent.java:newrelic-agent:6.0.0' implementation 'com.newrelic.agent.java:newrelic-api:6.0.0' implementation fileTree(include: ['*.jar'], dir: '../libs') @@ -14,15 +14,15 @@ dependencies { jar { manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.camel-core-3.18' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' + attributes 'Implementation-Title': 'com.newrelic.instrumentation.camel-core-3.18' + attributes 'Implementation-Vendor': 'New Relic' + attributes 'Implementation-Vendor-Id': 'com.newrelic' attributes 'Implementation-Version': 1.0 } } verifyInstrumentation { - passes 'org.apache.camel:camel-core:[3.18.0,4.0.0)' + passes 'org.apache.camel:camel-core:[3.18.0,)' excludeRegex '.*M[1-9]' excludeRegex '.*RC[1-9]' } diff --git a/camel-core-3.3/build.gradle b/camel-core-3.3/build.gradle index 828ef2a..020bbae 100644 --- a/camel-core-3.3/build.gradle +++ b/camel-core-3.3/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'java' dependencies { implementation 'org.apache.camel:camel-core:3.3.0' - // New Relic Labs Java Agent dependencies + // New Relic Java Agent dependencies implementation 'com.newrelic.agent.java:newrelic-agent:6.0.0' implementation 'com.newrelic.agent.java:newrelic-api:6.0.0' implementation fileTree(include: ['*.jar'], dir: '../libs') @@ -14,9 +14,9 @@ dependencies { jar { manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.camel-core-3.3' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' + attributes 'Implementation-Title': 'com.newrelic.instrumentation.camel-core-3.3' + attributes 'Implementation-Vendor': 'New Relic' + attributes 'Implementation-Vendor-Id': 'com.newrelic' attributes 'Implementation-Version': 1.0 } } diff --git a/camel-core-3.7.2/build.gradle b/camel-core-3.7.2/build.gradle index f2d2f71..61444a8 100644 --- a/camel-core-3.7.2/build.gradle +++ b/camel-core-3.7.2/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'java' dependencies { implementation 'org.apache.camel:camel-core:3.7.2' - // New Relic Labs Java Agent dependencies + // New Relic Java Agent dependencies implementation 'com.newrelic.agent.java:newrelic-agent:6.0.0' implementation 'com.newrelic.agent.java:newrelic-api:6.0.0' implementation fileTree(include: ['*.jar'], dir: '../libs') @@ -14,9 +14,9 @@ dependencies { jar { manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.camel-core-3.7.2' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' + attributes 'Implementation-Title': 'com.newrelic.instrumentation.camel-core-3.7.2' + attributes 'Implementation-Vendor': 'New Relic' + attributes 'Implementation-Vendor-Id': 'com.newrelic' attributes 'Implementation-Version': 1.0 } } diff --git a/camel-core-3.7/build.gradle b/camel-core-3.7/build.gradle index ce6cc90..ef5784c 100644 --- a/camel-core-3.7/build.gradle +++ b/camel-core-3.7/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'java' dependencies { implementation 'org.apache.camel:camel-core:3.7.0' - // New Relic Labs Java Agent dependencies + // New Relic Java Agent dependencies implementation 'com.newrelic.agent.java:newrelic-agent:6.0.0' implementation 'com.newrelic.agent.java:newrelic-api:6.0.0' implementation fileTree(include: ['*.jar'], dir: '../libs') @@ -14,9 +14,9 @@ dependencies { jar { manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.camel-core-3.7' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' + attributes 'Implementation-Title': 'com.newrelic.instrumentation.camel-core-3.7' + attributes 'Implementation-Vendor': 'New Relic' + attributes 'Implementation-Vendor-Id': 'com.newrelic' attributes 'Implementation-Version': 1.0 } } diff --git a/camel-core-3.9/build.gradle b/camel-core-3.9/build.gradle index fd7c772..0fa554b 100644 --- a/camel-core-3.9/build.gradle +++ b/camel-core-3.9/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'java' dependencies { implementation 'org.apache.camel:camel-core:3.9.0' - // New Relic Labs Java Agent dependencies + // New Relic Java Agent dependencies implementation 'com.newrelic.agent.java:newrelic-agent:6.0.0' implementation 'com.newrelic.agent.java:newrelic-api:6.0.0' implementation fileTree(include: ['*.jar'], dir: '../libs') @@ -14,9 +14,9 @@ dependencies { jar { manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.camel-core-3.9' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' + attributes 'Implementation-Title': 'com.newrelic.instrumentation.camel-core-3.9' + attributes 'Implementation-Vendor': 'New Relic' + attributes 'Implementation-Vendor-Id': 'com.newrelic' attributes 'Implementation-Version': 1.0 } } diff --git a/camel-core-4.0.0/build.gradle b/camel-core-4.0.0/build.gradle deleted file mode 100644 index bdcfead..0000000 --- a/camel-core-4.0.0/build.gradle +++ /dev/null @@ -1,30 +0,0 @@ - -// Build.gradle generated for instrumentation module camel-core-4.0.0 - -apply plugin: 'java' - -dependencies { - // Declare a dependency on each JAR you want to instrument - // Example: - implementation 'org.apache.camel:camel-core:4.0.0' - - // New Relic Labs Java Agent dependencies - implementation 'com.newrelic.agent.java:newrelic-agent:7.4.0' - implementation 'com.newrelic.agent.java:newrelic-api:7.4.0' - implementation fileTree(include: ['*.jar'], dir: '../libs') -} - -jar { - manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.camel-core-4.0.0' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' - attributes 'Implementation-Version': 1.0 - } -} - -verifyInstrumentation { - passes 'org.apache.camel:camel-core:[4.0.0,)' - excludeRegex '.*M[1-9]' - excludeRegex '.*RC[1-9]' -} \ No newline at end of file diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/AggregateProcessor_instrumentation.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/AggregateProcessor_instrumentation.java deleted file mode 100644 index 78f680d..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/AggregateProcessor_instrumentation.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.nr.instrumentation.apache.camel; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.AsyncCallback; -import org.apache.camel.Exchange; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.TransactionNamePriority; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; - -@Weave(originalName="org.apache.camel.processor.aggregate.AggregateProcessor") -public abstract class AggregateProcessor_instrumentation { - - @Trace(async=true) - protected boolean doProcess(Exchange exchange, AsyncCallback callback) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - String routeID = exchange != null ? exchange.getFromRouteId() : null; - if(routeID != null && !routeID.isEmpty()) { - NewRelic.getAgent().getTracedMethod().setMetricName(new String[] {"Custom","AggregateProcessor","doProcess",routeID}); - NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, false, "CamelProcessor", new String[] {"AggregateProcessor",routeID}); - } - Token token = exchange.getProperty(Util.NRTOKENPROPERTY,Token.class); - if(token != null) { - token.link(); - } - - return Weaver.callOriginal(); - } - - @Trace(async=true) - protected boolean doProcess(Exchange exchange, String key, AsyncCallback callback, boolean sync) { - String routeID = exchange != null ? exchange.getFromRouteId() : null; - if(routeID != null && !routeID.isEmpty()) { - NewRelic.addCustomParameter("From Route ID", routeID); - NewRelic.getAgent().getTracedMethod().setMetricName(new String[] {"Custom","AggregateProcessor","doProcess",routeID}); - NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, false, "CamelProcessor", new String[] {"AggregateProcessor",routeID}); - } - Token token = exchange.getProperty(Util.NRTOKENPROPERTY,Token.class); - if(token != null) { - token.link(); - } - - return Weaver.callOriginal(); - } -} diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/CamelInternalProcessor_instrumentation.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/CamelInternalProcessor_instrumentation.java deleted file mode 100644 index 07b243d..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/CamelInternalProcessor_instrumentation.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.nr.instrumentation.apache.camel; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.AsyncCallback; -import org.apache.camel.Exchange; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.TracedMethod; -import com.newrelic.api.agent.weaver.MatchType; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; - -@Weave(type=MatchType.BaseClass,originalName="org.apache.camel.impl.engine.CamelInternalProcessor") -public abstract class CamelInternalProcessor_instrumentation { - - @Trace(async=true) - public boolean process(Exchange exchange, AsyncCallback callback) { - Token token = exchange.getProperty(Util.NRTOKENPROPERTY,Token.class); - if(token != null && token.isActive()) { - token.link(); - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - - TracedMethod traced = NewRelic.getAgent().getTracedMethod(); - if(exchange != null && exchange.getFromRouteId() != null) { - traced.setMetricName("Custom","CamelInternalProcessor","process",exchange.getFromRouteId()); - } - if(!attributes.isEmpty()) { - traced.addCustomAttributes(attributes); - } - } - - return Weaver.callOriginal(); - } -} diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/ChoiceProcessor_instrumentation.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/ChoiceProcessor_instrumentation.java deleted file mode 100644 index 6aa9350..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/ChoiceProcessor_instrumentation.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.nr.instrumentation.apache.camel; - -import java.net.URI; -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.AsyncCallback; -import org.apache.camel.CamelContext; -import org.apache.camel.Endpoint; -import org.apache.camel.Exchange; -import org.apache.camel.Message; - -import com.newrelic.api.agent.HttpParameters; -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.TransactionNamePriority; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.apache.camel.wrappers.InboundMessageWrapper; - -@Weave(originalName="org.apache.camel.processor.ChoiceProcessor") -public abstract class ChoiceProcessor_instrumentation { - - @Trace(async=true) - public boolean process(Exchange exchange, AsyncCallback callback) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - String classname = getClass().getSimpleName(); - Token token = exchange.getProperty(Util.NRTOKENPROPERTY,Token.class); - if(token != null) { - token.link(); - } - Message inMessage = exchange.getIn(); - InboundMessageWrapper msgWrapper = new InboundMessageWrapper(inMessage); - Endpoint endpoint = exchange.getFromEndpoint(); - if(endpoint != null) { - String endpointURI = endpoint.getEndpointUri(); - if(endpointURI != null && !endpointURI.isEmpty()) { - URI uri = URI.create(endpointURI); - if(uri != null) { - HttpParameters params = HttpParameters.library("Camel").uri(uri).procedure("process").inboundHeaders(msgWrapper).build(); - NewRelic.getAgent().getTracedMethod().reportAsExternal(params); - } - - } - } - String routeID = exchange != null ? exchange.getFromRouteId() : null; - if(routeID != null && !routeID.isEmpty()) { - NewRelic.getAgent().getTracedMethod().setMetricName(new String[] {"Custom",classname,"process",routeID}); - NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, false, "ChoiceProcessor", new String[] {"ChoiceProcessor",routeID}); - } - return Weaver.callOriginal(); - } - -} diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/MultiCastProcessor_instrumentation.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/MultiCastProcessor_instrumentation.java deleted file mode 100644 index 163c8ff..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/MultiCastProcessor_instrumentation.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.nr.instrumentation.apache.camel; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.AsyncCallback; -import org.apache.camel.Exchange; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.weaver.MatchType; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; - -@Weave(type=MatchType.BaseClass,originalName="org.apache.camel.processor.MulticastProcessor") -public abstract class MultiCastProcessor_instrumentation { - - @Trace(async=true) - public boolean process(Exchange exchange, AsyncCallback callback) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - Token token = exchange.getProperty(Util.NRTOKENPROPERTY,Token.class); - if(token != null) { - token.link(); - } - - return Weaver.callOriginal(); - } - - @Weave(originalName="org.apache.camel.processor.MulticastProcessor$MulticastReactiveTask") - protected static abstract class MulticastReactiveTask { - - - @Trace(async=true) - public void run() { - Weaver.callOriginal(); - } - - } - -} diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRAsyncProcessorWrapper.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRAsyncProcessorWrapper.java deleted file mode 100644 index f47f9ec..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRAsyncProcessorWrapper.java +++ /dev/null @@ -1,82 +0,0 @@ -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.api.agent.Token; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.TransactionNamePriority; - -public class NRAsyncProcessorWrapper extends NRProcessorWrapper implements AsyncProcessor { - - public NRAsyncProcessorWrapper(AsyncProcessor p,Route r) { - super(p,r); - } - - @Override - @Trace(dispatcher=true) - public boolean process(Exchange exchange, AsyncCallback callback) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - Token token = exchange.getProperty(Util.NRTOKENPROPERTY,Token.class); - - if(token != null) { - token.link(); - } - - 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 { - names = new String[] {"Custom","AsyncProcessor",delegate.getClass().getSimpleName(),"process"}; - - } - NewRelic.getAgent().getTracedMethod().setMetricName(names); - return ((AsyncProcessor)delegate).process(exchange, callback); - } - - @Override - @Trace(async=true) - public CompletableFuture processAsync(Exchange exchange) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - Token token = exchange.getProperty(Util.NRTOKENPROPERTY,Token.class); - - if(token != null) { - token.link(); - } - - 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"}; - - } - NewRelic.getAgent().getTracedMethod().setMetricName(names); - return ((AsyncProcessor)delegate).processAsync(exchange); - } - -} diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRProcessorWrapper.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRProcessorWrapper.java deleted file mode 100644 index 71ee28f..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRProcessorWrapper.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.nr.instrumentation.apache.camel; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.Route; - -import com.newrelic.agent.bridge.AgentBridge; -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.Trace; - -public class NRProcessorWrapper implements Processor { - - private static boolean isTransformed = false; - protected Route route = null; - - protected Processor delegate = null; - - public NRProcessorWrapper(Processor p,Route r) { - delegate = p; - route = r; - if(!isTransformed) { - AgentBridge.instrumentation.retransformUninstrumentedClass(getClass()); - } - } - - @Override - @Trace(async=true) - public void process(Exchange exchange) throws Exception { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - Token token = exchange.getProperty(Util.NRTOKENPROPERTY,Token.class); - - if(token != null) { - token.link(); - } - if(route != null) { - String routeId = route.getId(); - if(routeId != null && !routeId.isEmpty()) { - NewRelic.getAgent().getTracedMethod().addCustomAttribute("RouteId", routeId); - NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Processor",delegate.getClass().getSimpleName(),"process",routeId); - } else { - NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Processor",delegate.getClass().getSimpleName(),"process"); - } - } else { - NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Processor",delegate.getClass().getSimpleName(),"process"); - } - if(delegate != null) { - delegate.process(exchange); - } - - } - -} diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRRunnable.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRRunnable.java deleted file mode 100644 index 08c8883..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRRunnable.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.nr.instrumentation.apache.camel; - -import com.newrelic.agent.bridge.AgentBridge; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.Trace; - -public class NRRunnable implements Runnable { - - private static boolean isTransformed = false; - - private Runnable delegate = null; - private Token token = null; - - public NRRunnable(Runnable d, Token t) { - if(!isTransformed) { - AgentBridge.instrumentation.retransformUninstrumentedClass(getClass()); - isTransformed = true; - } - delegate = d; - token = t; - } - - @Override - @Trace(async=true) - public void run() { - if(token != null) { - token.linkAndExpire(); - token = null; - } - delegate.run(); - } - -} diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRSynchronization.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRSynchronization.java deleted file mode 100644 index 538009a..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/NRSynchronization.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.nr.instrumentation.apache.camel; - -import org.apache.camel.Exchange; -import org.apache.camel.spi.Synchronization; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; - -public class NRSynchronization implements Synchronization { - - public NRSynchronization() { - } - - @Override - public void onComplete(Exchange exchange) { - if(exchange.hasProperties()) { - Token token = (Token) exchange.removeProperty(Util.NRTOKENPROPERTY); - if(token != null) { - token.expire(); - } - } - } - - @Override - public void onFailure(Exchange exchange) { - NewRelic.incrementCounter("/Custom/NRSynchronization/Failed"); - if(exchange.hasProperties()) { - Token token = (Token) exchange.removeProperty(Util.NRTOKENPROPERTY); - if(token != null) { - token.expire(); - } - } - if(exchange.isFailed()) { - Exception e = exchange.getException(); - if(e != null) { - NewRelic.noticeError(e); - } - } - - } - -} diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/Pipeline_instrumentation.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/Pipeline_instrumentation.java deleted file mode 100644 index f9b11b6..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/Pipeline_instrumentation.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.nr.instrumentation.apache.camel; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.AsyncCallback; -import org.apache.camel.Exchange; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; - -@Weave(originalName="org.apache.camel.processor.Pipeline") -public abstract class Pipeline_instrumentation { - - private String id = Weaver.callOriginal(); - - @Trace(async=true) - public boolean process(Exchange exchange, AsyncCallback callback) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - Token token = exchange.getProperty(Util.NRTOKENPROPERTY,Token.class); - - if(token != null) { - token.link(); - } else { - Token t = NewRelic.getAgent().getTransaction().getToken(); - if(t != null && t.isActive()) { - exchange.setProperty(Util.NRTOKENPROPERTY, t); - } else if(t != null) { - t.expire(); - t = null; - } - } - if(id != null) { - NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Pipeline","process",id); - NewRelic.getAgent().getTracedMethod().addCustomAttribute("PipelineID", id); - } else { - NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Pipeline","process"); - } - return Weaver.callOriginal(); - } - - @Weave(originalName="org.apache.camel.processor.Pipeline$PipelineTask") - private static class PipelineTask { - - private Exchange exchange = Weaver.callOriginal(); - - @Trace(async=true) - public void run() { - if(exchange != null) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - Token token = exchange.getProperty(Util.NRTOKENPROPERTY,Token.class); - - if(token != null) { - token.link(); - } - - } - Weaver.callOriginal(); - } - } - -} diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/SendProcessor_instrumentation.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/SendProcessor_instrumentation.java deleted file mode 100644 index 4b37d5a..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/SendProcessor_instrumentation.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.nr.instrumentation.apache.camel; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.AsyncCallback; -import org.apache.camel.Endpoint; -import org.apache.camel.Exchange; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.apache.camel.wrappers.OutboundExchangeWrapper; - -@Weave(originalName="org.apache.camel.processor.SendProcessor") -public abstract class SendProcessor_instrumentation { - - protected final Endpoint destination = Weaver.callOriginal(); - - @Trace(async=true) - public boolean process(Exchange exchange, AsyncCallback callback) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - Token token = exchange.getProperty(Util.NRTOKENPROPERTY,Token.class); - - if(token != null) { - token.link(); - } - - String dest = destination != null ? destination.getEndpointUri() : null; - if(dest != null && !dest.isEmpty()) { - NewRelic.getAgent().getTracedMethod().setMetricName("Custom","SendProcessor","process",dest); - NewRelic.getAgent().getTracedMethod().addCustomAttribute("DestinationURI", dest); - } - OutboundExchangeWrapper wrapper = new OutboundExchangeWrapper(exchange); - NewRelic.getAgent().getTracedMethod().addOutboundRequestHeaders(wrapper); - return Weaver.callOriginal(); - } - -} diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/SharedInternalProcessor_instrumentation.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/SharedInternalProcessor_instrumentation.java deleted file mode 100644 index 0c1db14..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/SharedInternalProcessor_instrumentation.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.nr.instrumentation.apache.camel; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.AsyncCallback; -import org.apache.camel.AsyncProcessor; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; - -@Weave(originalName="org.apache.camel.impl.engine.SharedCamelInternalProcessor") -public class SharedInternalProcessor_instrumentation { - - @Trace - public boolean process(Exchange exchange, AsyncCallback callback, AsyncProcessor processor, Processor resultProcessor) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - Token token = exchange.getProperty(Util.NRTOKENPROPERTY,Token.class); - - if(token != null) { - token.link(); - } - - return Weaver.callOriginal(); - } -} diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/Util.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/Util.java deleted file mode 100644 index ecf8f67..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/Util.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.nr.instrumentation.apache.camel; - -import java.lang.reflect.Method; -import java.util.List; -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.Endpoint; -import org.apache.camel.Exchange; -import org.apache.camel.spi.Synchronization; -import org.apache.camel.support.ExtendedExchangeExtension; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; - -public class Util { - - public static final String NRTOKENPROPERTY = "newrelic.asynctoken"; - - public static String getMethodName(Method m) { - if(m == null) return "UnknownClass.UnknownMethod"; - - String classname = m.getDeclaringClass().getSimpleName(); - String methodName = m.getName(); - - return classname + "." + methodName; - } - - public static void addCompletionIfNeeded(ExtendedExchangeExtension exchange) { - if(exchange == null) return; - - List completions = exchange.handoverCompletions(); - if(completions == null || completions.isEmpty()) { - NRSynchronization nrSync = new NRSynchronization(); - exchange.addOnCompletion(nrSync); - } else { - boolean hasNR = false; - for(int i=0; i attributes, Exchange exchange) { - if(exchange != null) { - recordValue(attributes, "ExchangeId", exchange.getExchangeId()); - CamelContext context = exchange.getContext(); - String ctxName = context != null ? context.getName() : null; - recordValue(attributes, "CamelContextName", ctxName); - recordValue(attributes, "CamelContextManagementName", context.getManagementName()); - Endpoint endpoint = exchange.getFromEndpoint(); - if(endpoint != null) { - recordValue(attributes, "From_EndPointURI", endpoint.getEndpointUri()); - } - recordValue(attributes, "FromRouteId", exchange.getFromRouteId()); - } - } - - private static void recordValue(Map attributes, String key, Object value) { - if(key != null && !key.isEmpty() && value != null) { - attributes.put(key, value); - } - } - -} \ No newline at end of file diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/wrappers/InboundExchangeWrapper.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/wrappers/InboundExchangeWrapper.java deleted file mode 100644 index fc4a86a..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/wrappers/InboundExchangeWrapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.nr.instrumentation.apache.camel.wrappers; - -import org.apache.camel.Exchange; - -import com.newrelic.api.agent.HeaderType; -import com.newrelic.api.agent.InboundHeaders; - -public class InboundExchangeWrapper implements InboundHeaders { - - private Exchange exchange; - - public InboundExchangeWrapper(Exchange ex) { - exchange = ex; - } - - public HeaderType getHeaderType() { - return HeaderType.HTTP; - } - - public String getHeader(String name) { - return (String) exchange.getProperty(name); - } - -} \ No newline at end of file diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/wrappers/InboundMessageWrapper.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/wrappers/InboundMessageWrapper.java deleted file mode 100644 index 0a5f947..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/wrappers/InboundMessageWrapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.nr.instrumentation.apache.camel.wrappers; - -import org.apache.camel.Message; - -import com.newrelic.api.agent.HeaderType; -import com.newrelic.api.agent.InboundHeaders; - -public class InboundMessageWrapper implements InboundHeaders { - - private Message message; - - public InboundMessageWrapper(Message msg) { - message = msg; - } - - public HeaderType getHeaderType() { - return HeaderType.MESSAGE; - } - - public String getHeader(String name) { - return (String) message.getHeader(name); - } - -} \ No newline at end of file diff --git a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/wrappers/OutboundExchangeWrapper.java b/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/wrappers/OutboundExchangeWrapper.java deleted file mode 100644 index 3f4d92d..0000000 --- a/camel-core-4.0.0/src/main/java/com/nr/instrumentation/apache/camel/wrappers/OutboundExchangeWrapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.nr.instrumentation.apache.camel.wrappers; - -import org.apache.camel.Exchange; - -import com.newrelic.api.agent.HeaderType; -import com.newrelic.api.agent.OutboundHeaders; - -public class OutboundExchangeWrapper implements OutboundHeaders { - - private Exchange exchange = null; - - public OutboundExchangeWrapper(Exchange e) { - exchange = e; - } - - @Override - public HeaderType getHeaderType() { - return HeaderType.MESSAGE; - } - - @Override - public void setHeader(String name, String value) { - exchange.setProperty(name, value); - } - -} diff --git a/camel-core-4.0.0/src/main/java/org/apache/camel/Endpoint.java b/camel-core-4.0.0/src/main/java/org/apache/camel/Endpoint.java deleted file mode 100644 index c3299e2..0000000 --- a/camel-core-4.0.0/src/main/java/org/apache/camel/Endpoint.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.apache.camel; - -import org.apache.camel.support.ExtendedExchangeExtension; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.weaver.MatchType; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.apache.camel.Util; - -@Weave(type=MatchType.Interface) -public abstract class Endpoint { - - - public abstract String getEndpointUri(); - - - public Exchange createExchange() { - Exchange exchange = Weaver.callOriginal(); - Token token = (Token) exchange.getProperty(Util.NRTOKENPROPERTY); - if(token == null) { - token = NewRelic.getAgent().getTransaction().getToken(); - if(token.isActive()) { - exchange.setProperty(Util.NRTOKENPROPERTY, token); - } else { - token.expire(); - } - } - if(exchange instanceof ExtendedExchangeExtension) { - Util.addCompletionIfNeeded((ExtendedExchangeExtension)exchange); - } - - return exchange; - } - - - public Exchange createExchange(ExchangePattern pattern) { - Exchange exchange = Weaver.callOriginal(); - Token token = (Token) exchange.getProperty(Util.NRTOKENPROPERTY); - if(token == null) { - token = NewRelic.getAgent().getTransaction().getToken(); - if(token.isActive()) { - exchange.setProperty(Util.NRTOKENPROPERTY, token); - } else { - token.expire(); - } - } - if(exchange instanceof ExtendedExchangeExtension) { - Util.addCompletionIfNeeded((ExtendedExchangeExtension)exchange); - } - - return exchange; - } - -} diff --git a/camel-core-4.0.0/src/main/java/org/apache/camel/component/bean/AbstractCamelInvocationHandler.java b/camel-core-4.0.0/src/main/java/org/apache/camel/component/bean/AbstractCamelInvocationHandler.java deleted file mode 100644 index 49f3909..0000000 --- a/camel-core-4.0.0/src/main/java/org/apache/camel/component/bean/AbstractCamelInvocationHandler.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.apache.camel.component.bean; - -import java.lang.reflect.Method; - -import org.apache.camel.ExchangePattern; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.weaver.MatchType; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; - -@Weave(type=MatchType.BaseClass) -public abstract class AbstractCamelInvocationHandler { - - @Trace - public Object doInvokeProxy(Object proxy, Method method, Object[] args) { - NewRelic.getAgent().getTracedMethod().setMetricName(new String[] {"Custom","Camel","CamelInvocationHandler",getClass().getSimpleName(),"doProxyInvoke",method.getDeclaringClass().getSimpleName(),method.getName()}); - return Weaver.callOriginal(); - } - - @Trace - protected Object invokeProxy(Method method, ExchangePattern pattern, Object[] args, boolean binding) { - NewRelic.getAgent().getTracedMethod().setMetricName(new String[] {"Custom","Camel","CamelInvocationHandler",getClass().getSimpleName(),"invokeProxy",method.getDeclaringClass().getSimpleName(),method.getName()}); - return Weaver.callOriginal(); - } - - @Trace - protected Object invokeWithBody(Method method, Object body, ExchangePattern pattern) { - NewRelic.getAgent().getTracedMethod().setMetricName(new String[] {"Custom","Camel","CamelInvocationHandler",getClass().getSimpleName(),"invokeWithBody",method.getDeclaringClass().getSimpleName(),method.getName()}); - return Weaver.callOriginal(); - } -} diff --git a/camel-core-4.0.0/src/main/java/org/apache/camel/component/bean/BeanProcessor.java b/camel-core-4.0.0/src/main/java/org/apache/camel/component/bean/BeanProcessor.java deleted file mode 100644 index e4073bd..0000000 --- a/camel-core-4.0.0/src/main/java/org/apache/camel/component/bean/BeanProcessor.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.camel.component.bean; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.AsyncCallback; -import org.apache.camel.Exchange; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.apache.camel.Util; - -@Weave -public abstract class BeanProcessor { - - public abstract String getMethod(); - - @Trace(async=true) - public boolean process(Exchange exchange, AsyncCallback callback) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - String m = exchange.getIn().getHeader(Exchange.BEAN_METHOD_NAME, getMethod(), String.class); - if(m != null) { - NewRelic.getAgent().getTracedMethod().setMetricName(new String[] {"Custom","BeanProcessor","process",m}); - NewRelic.getAgent().getTracedMethod().addCustomAttribute("Bean_Method", m); - } else { - NewRelic.getAgent().getTracedMethod().setMetricName(new String[] {"Custom","BeanProcessor","process"}); - } - Token token = exchange.getProperty(Util.NRTOKENPROPERTY,Token.class); - - if(token != null) { - token.link(); - } - return Weaver.callOriginal(); - } -} diff --git a/camel-core-4.0.0/src/main/java/org/apache/camel/component/bean/MethodInvocation.java b/camel-core-4.0.0/src/main/java/org/apache/camel/component/bean/MethodInvocation.java deleted file mode 100644 index 145c8e0..0000000 --- a/camel-core-4.0.0/src/main/java/org/apache/camel/component/bean/MethodInvocation.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.apache.camel.component.bean; - -import java.lang.reflect.Method; - -import org.apache.camel.AsyncCallback; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.weaver.MatchType; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.apache.camel.Util; - -@Weave(type=MatchType.Interface) -public abstract class MethodInvocation { - - public abstract Method getMethod(); - - @Trace - public boolean proceed(AsyncCallback callback) { - NewRelic.getAgent().getTracedMethod().setMetricName("Custom","MethodInvocation",getClass().getSimpleName(),"proceed",Util.getMethodName(getMethod())); - return Weaver.callOriginal(); - } -} diff --git a/camel-core-4.0.0/src/main/java/org/apache/camel/component/controlbus/ControlBusProducer.java b/camel-core-4.0.0/src/main/java/org/apache/camel/component/controlbus/ControlBusProducer.java deleted file mode 100644 index 6817b9d..0000000 --- a/camel-core-4.0.0/src/main/java/org/apache/camel/component/controlbus/ControlBusProducer.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.apache.camel.component.controlbus; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.AsyncCallback; -import org.apache.camel.Exchange; -import org.apache.camel.spi.Language; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.apache.camel.Util; - -@Weave -public abstract class ControlBusProducer { - - @Trace - public boolean process(Exchange exchange, AsyncCallback callback) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - return Weaver.callOriginal(); - } - - @Trace - protected void processByAction(Exchange exchange) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - Weaver.callOriginal(); - } - - @Trace - protected void processByLanguage(Exchange exchange, Language language) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - Weaver.callOriginal(); - } -} diff --git a/camel-core-4.0.0/src/main/java/org/apache/camel/component/seda/SedaProducer.java b/camel-core-4.0.0/src/main/java/org/apache/camel/component/seda/SedaProducer.java deleted file mode 100644 index 058aa25..0000000 --- a/camel-core-4.0.0/src/main/java/org/apache/camel/component/seda/SedaProducer.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.apache.camel.component.seda; - -import org.apache.camel.Exchange; - -import org.apache.camel.support.ExtendedExchangeExtension; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.apache.camel.Util; - -@Weave -public abstract class SedaProducer { - - protected void addToQueue(Exchange exchange, boolean copy) { - Token token = (Token) exchange.getProperty(Util.NRTOKENPROPERTY); - if(token == null) { - token = NewRelic.getAgent().getTransaction().getToken(); - if(token.isActive()) { - exchange.setProperty(Util.NRTOKENPROPERTY, token); - } else { - token.expire(); - } - } - if(exchange instanceof ExtendedExchangeExtension) { - Util.addCompletionIfNeeded((ExtendedExchangeExtension)exchange); - } - Weaver.callOriginal(); - } -} diff --git a/camel-core-4.0.0/src/main/java/org/apache/camel/impl/engine/DefaultProducerTemplate.java b/camel-core-4.0.0/src/main/java/org/apache/camel/impl/engine/DefaultProducerTemplate.java deleted file mode 100644 index 6ca632f..0000000 --- a/camel-core-4.0.0/src/main/java/org/apache/camel/impl/engine/DefaultProducerTemplate.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.apache.camel.impl.engine; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -import org.apache.camel.Endpoint; -import org.apache.camel.Exchange; -import org.apache.camel.ExchangePattern; -import org.apache.camel.Processor; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.TransactionNamePriority; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.apache.camel.NRProcessorWrapper; -import com.nr.instrumentation.apache.camel.Util; - -@Weave -public abstract class DefaultProducerTemplate { - - @Trace(dispatcher=true) - protected CompletableFuture asyncSendExchange(Endpoint endpoint, ExchangePattern pattern, Processor processor, Processor resultProcessor,Exchange inExchange) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, inExchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - Token token = (Token) inExchange.getProperty(Util.NRTOKENPROPERTY); - if(token == null) { - token = NewRelic.getAgent().getTransaction().getToken(); - if(token != null && token.isActive()) { - inExchange.setProperty(Util.NRTOKENPROPERTY, token); - } else if(token != null) { - token.expire(); - token = null; - } - } - if(endpoint != null) { - String uri = endpoint.getEndpointUri(); - if(uri != null && !uri.isEmpty()) { - NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, false, "Producer", "Custom","Producer",uri); - NewRelic.getAgent().getTracedMethod().addCustomAttribute("EndpointURI", uri); - } - } - if(resultProcessor != null && !(resultProcessor instanceof NRProcessorWrapper)) { - resultProcessor = new NRProcessorWrapper(resultProcessor, null); - } - return Weaver.callOriginal(); - } - - @Trace(dispatcher=true) - public Exchange send(Endpoint endpoint, Exchange exchange, Processor resultProcessor) { - Map attributes = new HashMap(); - Util.recordExchange(attributes, exchange); - NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); - Token token = (Token) exchange.getProperty(Util.NRTOKENPROPERTY); - if(token == null) { - token = NewRelic.getAgent().getTransaction().getToken(); - if(token != null && token.isActive()) { - exchange.setProperty(Util.NRTOKENPROPERTY, token); - } else if(token != null) { - token.expire(); - token = null; - } - } - if(endpoint != null) { - String uri = endpoint.getEndpointUri(); - if(uri != null && !uri.isEmpty()) { - NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, false, "Producer", "Custom","Producer",uri); - NewRelic.getAgent().getTracedMethod().addCustomAttribute("EndpointURI", uri); - } - } - if(resultProcessor != null && !(resultProcessor instanceof NRProcessorWrapper)) { - resultProcessor = new NRProcessorWrapper(resultProcessor, null); - } - return Weaver.callOriginal(); - } - - -} diff --git a/camel-core-4.0.0/src/main/java/org/apache/camel/support/DefaultConsumer.java b/camel-core-4.0.0/src/main/java/org/apache/camel/support/DefaultConsumer.java deleted file mode 100644 index 8050b0a..0000000 --- a/camel-core-4.0.0/src/main/java/org/apache/camel/support/DefaultConsumer.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.apache.camel.support; - -import org.apache.camel.AsyncProcessor; -import org.apache.camel.Endpoint; -import org.apache.camel.Processor; -import org.apache.camel.Route; - -import com.newrelic.api.agent.weaver.MatchType; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.apache.camel.NRAsyncProcessorWrapper; -import com.nr.instrumentation.apache.camel.NRProcessorWrapper; - -@Weave(type=MatchType.BaseClass) -public abstract class DefaultConsumer { - - public abstract Endpoint getEndpoint(); - - public abstract Route getRoute(); - - public synchronized AsyncProcessor getAsyncProcessor() { - AsyncProcessor asyncProcessor = Weaver.callOriginal(); - if(asyncProcessor != null && !(asyncProcessor instanceof NRAsyncProcessorWrapper)) { - return new NRAsyncProcessorWrapper(asyncProcessor,getRoute()); - } - return asyncProcessor; - } - - public Processor getProcessor() { - Processor processor = Weaver.callOriginal(); - if(!(processor instanceof NRProcessorWrapper)) { - return new NRProcessorWrapper(processor,getRoute()); - } - return processor; - } -} diff --git a/camel-core-4.0.0/src/main/java/org/apache/camel/support/DefaultProducer.java b/camel-core-4.0.0/src/main/java/org/apache/camel/support/DefaultProducer.java deleted file mode 100644 index 9a2c334..0000000 --- a/camel-core-4.0.0/src/main/java/org/apache/camel/support/DefaultProducer.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.apache.camel.support; - -import org.apache.camel.Exchange; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.weaver.MatchType; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.apache.camel.Util; - -@Weave(type=MatchType.BaseClass) -public abstract class DefaultProducer { - - public Exchange createExchange() { - Exchange exchange = Weaver.callOriginal(); - Token token = (Token) exchange.getProperty(Util.NRTOKENPROPERTY); - if(token == null) { - token = NewRelic.getAgent().getTransaction().getToken(); - if(token.isActive()) { - exchange.setProperty(Util.NRTOKENPROPERTY, token); - } else { - token.expire(); - } - } - if(exchange instanceof ExtendedExchangeExtension) { - Util.addCompletionIfNeeded((ExtendedExchangeExtension)exchange); - } - - return exchange; - } - -} diff --git a/camel-core-4.0.0/src/main/java/org/apache/camel/support/ExchangeHelper.java b/camel-core-4.0.0/src/main/java/org/apache/camel/support/ExchangeHelper.java deleted file mode 100644 index 19dc537..0000000 --- a/camel-core-4.0.0/src/main/java/org/apache/camel/support/ExchangeHelper.java +++ /dev/null @@ -1,67 +0,0 @@ - package org.apache.camel.support; - -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; - - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.apache.camel.Util; - -@Weave -public class ExchangeHelper { - - public static Exchange copyExchangeAndSetCamelContext(Exchange exchange, CamelContext context, boolean handover) { - Exchange result = Weaver.callOriginal(); - if(result instanceof ExtendedExchangeExtension) { - Util.addCompletionIfNeeded((ExtendedExchangeExtension)exchange); - } - - if(handover) { - Token token = (Token) exchange.getProperty(Util.NRTOKENPROPERTY); - if(token != null) { - result.setProperty(Util.NRTOKENPROPERTY, token); - exchange.removeProperty(Util.NRTOKENPROPERTY); - } else { - token = NewRelic.getAgent().getTransaction().getToken(); - if(token != null && token.isActive()) { - result.setProperty(Util.NRTOKENPROPERTY, token); - } else if(token != null) { - token.expire(); - token = null; - } - } - } - - return result; - } - - public static Exchange createCopy(Exchange exchange, boolean preserveExchangeId) { - Exchange result = Weaver.callOriginal(); - if(result instanceof ExtendedExchangeExtension) { - Util.addCompletionIfNeeded((ExtendedExchangeExtension)exchange); - } - return result; - } - - public static Exchange createCorrelatedCopy(Exchange exchange, boolean handover, boolean useSameMessageId) { - Exchange result = Weaver.callOriginal(); - if(result instanceof ExtendedExchangeExtension) { - Util.addCompletionIfNeeded((ExtendedExchangeExtension)exchange); - } - - if (handover) { - Token token = (Token) exchange.getProperty(Util.NRTOKENPROPERTY); - if(token != null) { - token.expire(); - } - Util.addNewToken(result); - } - return result; - } - - - -} diff --git a/camel-core-4.0.0/src/main/java/org/apache/camel/support/component/ApiMethodHelper.java b/camel-core-4.0.0/src/main/java/org/apache/camel/support/component/ApiMethodHelper.java deleted file mode 100644 index 4257eec..0000000 --- a/camel-core-4.0.0/src/main/java/org/apache/camel/support/component/ApiMethodHelper.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.apache.camel.support.component; - -import java.util.Map; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; - -@Weave -public abstract class ApiMethodHelper { - - @Trace - public static Object invokeMethod(Object proxy, ApiMethod method, Map properties) { - NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Camel","ApiMethodHelper","invokeMethod",method.getName()); - return Weaver.callOriginal(); - } -} diff --git a/camel-jms-3.18/build.gradle b/camel-jms-3.18/build.gradle index ef8e57f..ee817f7 100644 --- a/camel-jms-3.18/build.gradle +++ b/camel-jms-3.18/build.gradle @@ -5,26 +5,25 @@ apply plugin: 'java' dependencies { implementation 'org.apache.camel:camel-jms:3.18.0' - //implementation 'javax.jms:javax.jms-api:2.0' - implementation 'jakarta.jms:jakarta.jms-api:3.1.0' + implementation 'javax.jms:javax.jms-api:2.0' - // New Relic Labs Java Agent dependencies - implementation 'com.newrelic.agent.java:newrelic-agent:7.4.0' - implementation 'com.newrelic.agent.java:newrelic-api:7.4.0' + // New Relic Java Agent dependencies + implementation 'com.newrelic.agent.java:newrelic-agent:6.4.0' + implementation 'com.newrelic.agent.java:newrelic-api:6.4.0' implementation fileTree(include: ['*.jar'], dir: '../libs') } jar { manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.camel-jms-3.18' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' + attributes 'Implementation-Title': 'com.newrelic.instrumentation.camel-jms-3.18' + attributes 'Implementation-Vendor': 'New Relic' + attributes 'Implementation-Vendor-Id': 'com.newrelic' attributes 'Implementation-Version': 1.0 } } verifyInstrumentation { - passes 'org.apache.camel:camel-jms:[3.18.0,4.0.0)' + passes 'org.apache.camel:camel-jms:[3.18.0,)' excludeRegex '.*M[1-9]' excludeRegex '.*RC[1-9]' } diff --git a/camel-jms-4.0.0/build.gradle b/camel-jms-4.0.0/build.gradle deleted file mode 100644 index ab4d0d8..0000000 --- a/camel-jms-4.0.0/build.gradle +++ /dev/null @@ -1,30 +0,0 @@ - -// Build.gradle generated for instrumentation module camel-jms-4.0.0 - -apply plugin: 'java' - -dependencies { - - implementation 'org.apache.camel:camel-jms:4.0.0' - implementation 'javax.jms:javax.jms-api:2.0' - - // New Relic Labs Java Agent dependencies - implementation 'com.newrelic.agent.java:newrelic-agent:7.4.0' - implementation 'com.newrelic.agent.java:newrelic-api:7.4.0' - implementation fileTree(include: ['*.jar'], dir: '../libs') -} - -jar { - manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.camel-jms-4.0.0' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' - attributes 'Implementation-Version': 1.0 - } -} - -verifyInstrumentation { - passes 'org.apache.camel:camel-jms:[4.0.0,)' - excludeRegex '.*M[1-9]' - excludeRegex '.*RC[1-9]' -} \ No newline at end of file diff --git a/camel-jms-4.0.0/src/main/java/com/nr/instrumentation/camel/jms/JMSHeaders.java b/camel-jms-4.0.0/src/main/java/com/nr/instrumentation/camel/jms/JMSHeaders.java deleted file mode 100644 index bfb76bc..0000000 --- a/camel-jms-4.0.0/src/main/java/com/nr/instrumentation/camel/jms/JMSHeaders.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.nr.instrumentation.camel.jms; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.logging.Level; - -import com.newrelic.api.agent.HeaderType; -import com.newrelic.api.agent.Headers; -import com.newrelic.api.agent.NewRelic; -import jakarta.jms.JMSException; - -public class JMSHeaders implements Headers { - - private jakarta.jms.Message message = null; - - public JMSHeaders(jakarta.jms.Message msg) { - message = msg; - } - - @Override - public HeaderType getHeaderType() { - return HeaderType.MESSAGE; - } - - @Override - public String getHeader(String name) { - try { - return message.getStringProperty(name); - } catch (JMSException e) { - NewRelic.getAgent().getLogger().log(Level.FINEST, e, "Error getting header: {0}",name); - } - return null; - } - - @Override - public Collection getHeaders(String name) { - List list = new ArrayList(); - try { - String value = message.getStringProperty(name); - if(value != null && !value.isEmpty()) { - list.add(value); - } - } catch(JMSException e) { - NewRelic.getAgent().getLogger().log(Level.FINEST, e, "Error getting header: {0}",name); - } - return list; - } - - @Override - public void setHeader(String name, String value) { - try { - message.setStringProperty(name, value); - } catch(JMSException e) { - NewRelic.getAgent().getLogger().log(Level.FINEST, e, "Error setting header: {0}",name); - } - } - - @Override - public void addHeader(String name, String value) { - try { - message.setStringProperty(name, value); - } catch(JMSException e) { - NewRelic.getAgent().getLogger().log(Level.FINEST, e, "Error adding header: {0}",name); - } - } - - @SuppressWarnings("unchecked") - @Override - public Collection getHeaderNames() { - try { - return Collections.list(message.getPropertyNames()); - } catch (JMSException e) { - NewRelic.getAgent().getLogger().log(Level.FINEST, e, "Error finding header names"); - } - return Collections.emptyList(); - } - - @Override - public boolean containsHeader(String name) { - try { - return message.propertyExists(name); - } catch (JMSException e) { - NewRelic.getAgent().getLogger().log(Level.FINEST, e, "Error finding header: {0}",name); - } - return false; - } - -} diff --git a/camel-jms-4.0.0/src/main/java/com/nr/instrumentation/camel/jms/OutboundMsgWrapper.java b/camel-jms-4.0.0/src/main/java/com/nr/instrumentation/camel/jms/OutboundMsgWrapper.java deleted file mode 100644 index 5f9f597..0000000 --- a/camel-jms-4.0.0/src/main/java/com/nr/instrumentation/camel/jms/OutboundMsgWrapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.nr.instrumentation.camel.jms; - -import com.newrelic.api.agent.HeaderType; -import com.newrelic.api.agent.OutboundHeaders; -import javax.jms.JMSException; -import javax.jms.Message; - -public class OutboundMsgWrapper implements OutboundHeaders { - private jakarta.jms.Message message = null; - - public OutboundMsgWrapper(jakarta.jms.Message msg) { - this.message = msg; - } - - public HeaderType getHeaderType() { - return HeaderType.MESSAGE; - } - - public void setHeader(String name, String value) { - try { - if (this.message != null && !this.message.propertyExists(name)) - this.message.setStringProperty(name, value); - } catch (jakarta.jms.JMSException jMSException) {} - } -} diff --git a/camel-jms-4.0.0/src/main/java/com/nr/instrumentation/camel/jms/OutboundWrapper.java b/camel-jms-4.0.0/src/main/java/com/nr/instrumentation/camel/jms/OutboundWrapper.java deleted file mode 100644 index aeb05c9..0000000 --- a/camel-jms-4.0.0/src/main/java/com/nr/instrumentation/camel/jms/OutboundWrapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.nr.instrumentation.camel.jms; - -import com.newrelic.api.agent.HeaderType; -import com.newrelic.api.agent.OutboundHeaders; -import org.apache.camel.Message; - -public class OutboundWrapper implements OutboundHeaders { - private Message msg = null; - - public OutboundWrapper(Message m) { - this.msg = m; - } - - public HeaderType getHeaderType() { - return HeaderType.MESSAGE; - } - - public void setHeader(String name, String value) { - if (this.msg != null) - this.msg.setHeader(name, value); - } -} diff --git a/camel-jms-4.0.0/src/main/java/com/nr/instrumentation/camel/jms/Util.java b/camel-jms-4.0.0/src/main/java/com/nr/instrumentation/camel/jms/Util.java deleted file mode 100644 index c1778ec..0000000 --- a/camel-jms-4.0.0/src/main/java/com/nr/instrumentation/camel/jms/Util.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.nr.instrumentation.camel.jms; - -import java.lang.reflect.Method; -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.Endpoint; -import org.apache.camel.Exchange; -import org.apache.camel.Message; - -public class Util { - - public static final String NRTOKENPROPERTY = "newrelic.asynctoken"; - - public static String getMethodName(Method m) { - if(m == null) return "UnknownClass.UnknownMethod"; - - String classname = m.getDeclaringClass().getSimpleName(); - String methodName = m.getName(); - - return classname + "." + methodName; - } - - public static void recordExchange(Exchange exchange, Map attributes) { - recordValue(attributes, "ExchangeId", exchange.getExchangeId()); - CamelContext context = exchange.getContext(); - if(context != null) { - recordCamelContext(context, attributes); - } - Endpoint fromEndpt = exchange.getFromEndpoint(); - if(fromEndpt != null) { - recordValue(attributes, "FromEndpoint-Key", fromEndpt.getEndpointKey()); - recordValue(attributes, "FromEndpoint-URI", fromEndpt.getEndpointUri()); - } - recordValue(attributes, "FromRouteId", exchange.getFromRouteId()); - Message inMsg = exchange.getIn(); - if(inMsg != null) { - recordValue(attributes, "In-MessageId", inMsg.getMessageId()); - } - Message outMsg = exchange.getOut(); - if(outMsg != null) { - recordValue(attributes, "Out-MessageId", outMsg.getMessageId()); - } - - } - - public static void recordCamelContext(CamelContext context, Map attributes) { - recordValue(attributes, "CamelContext-Name", context.getName()); - recordValue(attributes, "CamelContext-ManagementName", context.getManagementName()); - } - - public static void recordValue(Map attributes, String key, Object value) { - if(key != null && !key.isEmpty() && value != null) { - attributes.put(key, value); - } - } -} \ No newline at end of file diff --git a/camel-jms-4.0.0/src/main/java/org/apache/camel/component/jms/JmsBinding.java b/camel-jms-4.0.0/src/main/java/org/apache/camel/component/jms/JmsBinding.java deleted file mode 100644 index 9a966f5..0000000 --- a/camel-jms-4.0.0/src/main/java/org/apache/camel/component/jms/JmsBinding.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.apache.camel.component.jms; - -import java.util.Map; - -//import javax.jms.Message; -//import javax.jms.Session; - -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.OutboundHeaders; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.camel.jms.JMSHeaders; -import com.nr.instrumentation.camel.jms.OutboundMsgWrapper; - -import jakarta.jms.Message; -import jakarta.jms.Session; - -@Weave -public abstract class JmsBinding { - protected Message createJmsMessage(Exception cause, Session session) { - Message msg = (Message)Weaver.callOriginal(); - OutboundMsgWrapper wrapper = new OutboundMsgWrapper(msg); - NewRelic.getAgent().getTracedMethod().addOutboundRequestHeaders((OutboundHeaders)wrapper); - JMSHeaders headers = new JMSHeaders(msg); - NewRelic.getAgent().getTransaction().insertDistributedTraceHeaders(headers); - return msg; - } - - protected Message createJmsMessage(Exchange exchange, Object body, Map headers, Session session, CamelContext context) { - Message msg = (Message)Weaver.callOriginal(); - JMSHeaders jmsHeaders = new JMSHeaders(msg); - NewRelic.getAgent().getTransaction().insertDistributedTraceHeaders(jmsHeaders); - return msg; - } - - protected Message createJmsMessageForType(Exchange exchange, Object body, Session session, CamelContext context, JmsMessageType type) { - Message msg = (Message)Weaver.callOriginal(); - JMSHeaders jmsHeaders = new JMSHeaders(msg); - NewRelic.getAgent().getTransaction().insertDistributedTraceHeaders(jmsHeaders); - return msg; - } - - public Message makeJmsMessage(Exchange exchange, org.apache.camel.Message camelMessage, Session session, Exception cause) { - Message msg = (Message)Weaver.callOriginal(); - JMSHeaders jmsHeaders = new JMSHeaders(msg); - NewRelic.getAgent().getTransaction().insertDistributedTraceHeaders(jmsHeaders); - return msg; - } -} diff --git a/camel-jms-4.0.0/src/main/java/org/apache/camel/component/jms/JmsProducer.java b/camel-jms-4.0.0/src/main/java/org/apache/camel/component/jms/JmsProducer.java deleted file mode 100644 index 363038d..0000000 --- a/camel-jms-4.0.0/src/main/java/org/apache/camel/component/jms/JmsProducer.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.apache.camel.component.jms; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.OutboundHeaders; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.camel.jms.OutboundWrapper; -import org.apache.camel.AsyncCallback; -import org.apache.camel.Exchange; -import org.apache.camel.Message; - -@Weave -public abstract class JmsProducer { - @Trace - protected boolean processInOnly(Exchange exchange, AsyncCallback callback) { - Message msg = exchange.getIn(); - NewRelic.getAgent().getTracedMethod().addOutboundRequestHeaders((OutboundHeaders)new OutboundWrapper(msg)); - return ((Boolean)Weaver.callOriginal()).booleanValue(); - } - - @Trace - protected boolean processInOut(Exchange exchange, AsyncCallback callback) { - Message msg = exchange.getIn(); - NewRelic.getAgent().getTracedMethod().addOutboundRequestHeaders((OutboundHeaders)new OutboundWrapper(msg)); - return ((Boolean)Weaver.callOriginal()).booleanValue(); - } -} diff --git a/camel-jms/build.gradle b/camel-jms/build.gradle index 667eaa0..a8d3ce0 100644 --- a/camel-jms/build.gradle +++ b/camel-jms/build.gradle @@ -7,17 +7,17 @@ dependencies { implementation 'org.apache.camel:camel-jms:2.16.0' implementation 'javax.jms:javax.jms-api:2.0' - // New Relic Labs Java Agent dependencies - implementation 'com.newrelic.agent.java:newrelic-agent:7.4.0' - implementation 'com.newrelic.agent.java:newrelic-api:7.4.0' + // New Relic Java Agent dependencies + implementation 'com.newrelic.agent.java:newrelic-agent:6.4.0' + implementation 'com.newrelic.agent.java:newrelic-api:6.4.0' implementation fileTree(include: ['*.jar'], dir: '../libs') } jar { manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.camel-jms' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' + attributes 'Implementation-Title': 'com.newrelic.instrumentation.camel-jms' + attributes 'Implementation-Vendor': 'New Relic' + attributes 'Implementation-Vendor-Id': 'com.newrelic' attributes 'Implementation-Version': 1.0 } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102..a4f0001 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index ac3f9af..72f73ad 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,5 +11,3 @@ include 'camel-core-3.9' include 'camel-core-3.18' include 'camel-jms' include 'camel-jms-3.18' -include 'camel-core-4.0.0' -include 'camel-jms-4.0.0'