diff --git a/functional_test/src/test/java/com/newrelic/agent/instrumentation/ClassTransformerTest.java b/functional_test/src/test/java/com/newrelic/agent/instrumentation/ClassTransformerTest.java index 64f9a0a7e1..01c148bd62 100644 --- a/functional_test/src/test/java/com/newrelic/agent/instrumentation/ClassTransformerTest.java +++ b/functional_test/src/test/java/com/newrelic/agent/instrumentation/ClassTransformerTest.java @@ -21,8 +21,6 @@ import com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringDispatcherPointCut; import com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringExceptionHandlerPointCut; import com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringPointCut; -import com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.StrutsActionConfigMatcherPointCut; -import com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.StrutsActionPointCut; import com.newrelic.agent.service.ServiceFactory; import org.junit.Assert; import org.junit.Test; @@ -54,9 +52,6 @@ public void test() { } List manual = Arrays.asList( - // struts - new StrutsActionPointCut(classTransformer), - new StrutsActionConfigMatcherPointCut(classTransformer), // Spring new SpringPointCut(classTransformer), // new SpringWildcardPathPointCut(classTransformer), diff --git a/instrumentation/aws-wrap-0.7.0/README.md b/instrumentation/aws-wrap-0.7.0/README.md deleted file mode 100644 index 297cb447a6..0000000000 --- a/instrumentation/aws-wrap-0.7.0/README.md +++ /dev/null @@ -1,12 +0,0 @@ -## Building - -New Relic does not distribute the jar(s) required to build this instrumentation module nor are they available from a public repository such as Maven Central or jcenter. - -To build this instrumentation module you must provide the jar(s) and place them into the `/lib` subdirectory as follows: - -```groovy -instrumentation/aws-wrap-0.7.0/lib/aws-wrap_2.10-0.9.2.jar -``` - -## Required jar versions -`aws-wrap_2.10` - 0.9.0 or above diff --git a/instrumentation/aws-wrap-0.7.0/build.gradle b/instrumentation/aws-wrap-0.7.0/build.gradle deleted file mode 100644 index 2a7f420ea0..0000000000 --- a/instrumentation/aws-wrap-0.7.0/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -apply plugin: 'scala' - -isScalaProjectEnabled(project, "scala-2.10") - -dependencies { - implementation(project(":newrelic-api")) - implementation(project(":agent-bridge")) - implementation(project(":newrelic-weaver-api")) - implementation(project(":newrelic-weaver-scala-api")) - implementation("org.scala-lang:scala-library:2.10.7") - // com.github.dwhjames:aws-wrap_2.10:0.9.2 is expected to be in the lib folder - implementation(fileTree(include: ["*.jar"], dir: "lib")) - - testImplementation("com.amazonaws:aws-java-sdk:1.10.64") - testImplementation(project(":instrumentation:aws-java-sdk-s3-1.2.13")){ transitive = false } -} - -def shouldBuild = fileTree(include: ["*.jar"], dir: "lib").size() > 0 - -compileJava { - enabled(shouldBuild) -} - -compileTestJava { - enabled(shouldBuild) -} - -tasks.getByName("writeCachedWeaveAttributes").enabled(shouldBuild) - -jar { - enabled(shouldBuild) - manifest { attributes 'Implementation-Title': 'com.newrelic.instrumentation.aws-wrap-0.7.0' } -} - -site { - title 'AWS Wrap' - type 'Other' - versionOverride '[0.7.0,)' -} \ No newline at end of file diff --git a/instrumentation/aws-wrap-0.7.0/lib/.gitignore b/instrumentation/aws-wrap-0.7.0/lib/.gitignore deleted file mode 100644 index c96a04f008..0000000000 --- a/instrumentation/aws-wrap-0.7.0/lib/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/instrumentation/aws-wrap-0.7.0/src/integrationTest/scala/com/nr/agent/test/S3WrapTest.scala b/instrumentation/aws-wrap-0.7.0/src/integrationTest/scala/com/nr/agent/test/S3WrapTest.scala deleted file mode 100644 index 939b0e8d87..0000000000 --- a/instrumentation/aws-wrap-0.7.0/src/integrationTest/scala/com/nr/agent/test/S3WrapTest.scala +++ /dev/null @@ -1,106 +0,0 @@ -package com.nr.agent.test - -import com.amazonaws.auth.profile.ProfileCredentialsProvider -import com.amazonaws.services.s3.model.{ Bucket, ListBucketsRequest, ListObjectsRequest, ObjectListing } -import com.amazonaws.services.s3.{ AmazonS3, AmazonS3Client } -import com.github.dwhjames.awswrap.s3.AmazonS3ScalaClient -import com.newrelic.agent.introspec.{ ExternalRequest, InstrumentationTestConfig, InstrumentationTestRunner, Introspector, MetricsHelper, TransactionEvent } -import com.newrelic.api.agent.Trace -import org.junit.{Test, Assert} -import org.junit.runner.RunWith - -import scala.concurrent.{ Await, Future } -import scala.concurrent.duration._ - -import java.util.Collection; - -@RunWith(classOf[InstrumentationTestRunner]) -@InstrumentationTestConfig(includePrefixes = Array("com.github.dwhjames.awswrap", "com.amazonaws.services.s3")) -class S3WrapTest { - private val bucketName: String = "nr-java-agent-aits" - private val host: String = "amazon" - private val client: String = "S3" - - private def assertAwsMetrics(operation: String): Unit = { - val introspector :Introspector = InstrumentationTestRunner.getIntrospector() - Assert.assertEquals(1, introspector.getFinishedTransactionCount()) - val clientTx: String = introspector.getTransactionNames().iterator().next() - - Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/all")); - Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/allOther")); - Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/"+host+"/all")); - Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/"+host+"/"+client)); - - // Events - val transactionEvents :Collection[TransactionEvent] = introspector.getTransactionEvents(clientTx); - Assert.assertEquals(1, transactionEvents.size()); - val transactionEvent :TransactionEvent = transactionEvents.iterator().next(); - Assert.assertEquals(1, transactionEvent.getExternalCallCount()); - - // tracer's metric name: External/amazon/S3 - val scopedMetricName :String = "External/"+host+"/"+client; - Assert.assertEquals(1, MetricsHelper.getScopedMetricCount(clientTx, scopedMetricName)); - // tracer's segment name example: External/amazon/S3/listBuckets - val segmentName :String = "External/"+host+"/"+client+"/"+operation; - - val externalRequests :Collection[ExternalRequest] = introspector.getExternalRequests(clientTx); - Assert.assertEquals(1, externalRequests.size()); - val externalRequest : ExternalRequest = externalRequests.iterator().next(); - Assert.assertEquals(1, externalRequest.getCount()); - Assert.assertEquals(host, externalRequest.getHostname()); - Assert.assertEquals(client, externalRequest.getLibrary()); - Assert.assertEquals(operation, externalRequest.getOperation()); - } - - /** - * Assert that AWS instrumentation is working normally. - */ - @Test - def testAwsInstrumentation() { - syncAwsRequest() - assertAwsMetrics("listObjects") - } - - @Trace(dispatcher = true) - def syncAwsRequest(): Unit = { - val s3client: AmazonS3 = new AmazonS3Client(new ProfileCredentialsProvider()) - Assert.assertNotNull(s3client) - val listObjReq: ListObjectsRequest = new ListObjectsRequest() - listObjReq.setBucketName(bucketName) - val objsInBucket: ObjectListing = s3client.listObjects(listObjReq) - System.out.println("Got objects from bucket: "+objsInBucket.getBucketName) - Assert.assertEquals(bucketName, objsInBucket.getBucketName) - } - - @Test - def testAsyncListObjects() { - asyncListObjects() - assertAwsMetrics("listObjects") - } - - @Trace(dispatcher = true) - def asyncListObjects(): Unit = { - val s3client: AmazonS3ScalaClient = new AmazonS3ScalaClient(new ProfileCredentialsProvider()) - Assert.assertNotNull(s3client) - val listObjReq: ListObjectsRequest = new ListObjectsRequest() - listObjReq.setBucketName(bucketName) - val objsInBucket: ObjectListing = Await.result(s3client.listObjects(listObjReq), 30 seconds) - System.out.println("Got objects from bucket: "+objsInBucket.getBucketName) - Assert.assertEquals(bucketName, objsInBucket.getBucketName) - } - - @Test - def testAsyncListBuckets() { - asyncListBuckets() - assertAwsMetrics("listBuckets") - } - - @Trace(dispatcher = true) - def asyncListBuckets(): Unit = { - val s3client: AmazonS3ScalaClient = new AmazonS3ScalaClient(new ProfileCredentialsProvider()) - Assert.assertNotNull(s3client) - val listBucketsReq: ListBucketsRequest = new ListBucketsRequest() - val buckets: Seq[Bucket] = Await.result(s3client.listBuckets(), 30 seconds) - Assert.assertTrue(buckets.size > 0) - } -} diff --git a/instrumentation/aws-wrap-0.7.0/src/main/scala/com/github/dwhjames/awswrap/S3WrapInstrumentation.scala b/instrumentation/aws-wrap-0.7.0/src/main/scala/com/github/dwhjames/awswrap/S3WrapInstrumentation.scala deleted file mode 100644 index 8d1a814b75..0000000000 --- a/instrumentation/aws-wrap-0.7.0/src/main/scala/com/github/dwhjames/awswrap/S3WrapInstrumentation.scala +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.github.dwhjames.awswrap.s3.instrumentation - -import java.io.File -import java.net.URL - -import scala.concurrent.Future - -import com.newrelic.agent.bridge.AgentBridge -import com.newrelic.api.agent.weaver.{Weave, Weaver} - -@Weave(originalName="com.github.dwhjames.awswrap.s3.AmazonS3ScalaClient") -class AmazonS3ScalaClient { - /** - * In the original code this method is annotated with @inline. - * In the bytecode it is not actually inlined, so it's safe to instrument. - * Future versions could fail because scalac decides to actually inline this method. - */ - private def wrapMethod[Request, Result]( - f: Request => Result, - request: Request - ): Future[Result] = { - val tx = AgentBridge.getAgent().getTransaction(false) - if (null != tx && tx.isStarted()) { - tx.registerAsyncActivity(request); - } - Weaver.callOriginal() - } -} diff --git a/instrumentation/aws-wrap-0.7.0/src/main/scala/com/github/dwhjames/awswrap/S3WrapRunnable.java b/instrumentation/aws-wrap-0.7.0/src/main/scala/com/github/dwhjames/awswrap/S3WrapRunnable.java deleted file mode 100644 index 20fc6cdc81..0000000000 --- a/instrumentation/aws-wrap-0.7.0/src/main/scala/com/github/dwhjames/awswrap/S3WrapRunnable.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.github.dwhjames.awswrap; - -import com.newrelic.agent.bridge.AgentBridge; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; - -/** - * Anonymous inner runnable which runs the aws command on another thread. - */ -@Weave(originalName="com.github.dwhjames.awswrap.s3.AmazonS3ScalaClient$$anon$1") -public final class S3WrapRunnable implements java.lang.Runnable { - // need to use java to access this field. - public final Object request$1 = Weaver.callOriginal(); - - @Trace(async = true) - public void run() { - if (AgentBridge.getAgent().startAsyncActivity(request$1)) { - AgentBridge.getAgent().getTransaction().getTracedMethod().setMetricName("S3Wrap"); - } - Weaver.callOriginal(); - } -} diff --git a/instrumentation/java.completable-future-jdk8/README.md b/instrumentation/java.completable-future-jdk8/README.md deleted file mode 100644 index fda331723f..0000000000 --- a/instrumentation/java.completable-future-jdk8/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# java.completable-future-jdk8 - -This instrumentation weaves `java.util.concurrent.CompletableFuture` and `java.util.concurrent.CompletableFuture$Async` to -trace code execution across asynchronous boundaries. - -## How it works - -Some context on parallelism according to comments in the -[CompletableFuture source](http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/util/concurrent/CompletableFuture.java#l77): - -> * All async methods without an explicit Executor -> * argument are performed using the {@link ForkJoinPool#commonPool()} -> * (unless it does not support a parallelism level of at least two, in -> * which case, a new Thread is used). To simplify monitoring, -> * debugging, and tracking, all generated asynchronous tasks are -> * instances of the marker interface {@link -> * AsynchronousCompletionTask}. - -When `CompletableFuture.execAsync(Executor e, Async r)` is invoked, it "starts the given async task using the given executor, -unless the executor is `ForkJoinPool.commonPool` and it has been disabled, in which case starts a new thread." - -Instrumented code: - -```java - static void execAsync(Executor e, CompletableFuture_Instrumentation.Async r) { - if (noParallelism(e)) { - new Thread(new TokenAwareRunnable(r)).start(); - } else { - Executor tde = useTokenDelegateExecutor(e); - if (null != tde) { - tde.execute(r); - } - } - } -``` - -### Case 1: No Parallelism - -If there is no parallelism this instrumentation will initialize a new `Thread` with a `TokenAwareRunnable` that wraps the `CompletableFuture$Async` argument -passed to `execAsync`. The `TokenAwareRunnable` uses `TokenAndRefUtils` to get a `TokenAndRefCount`, if one exists, for the current `Thread`. Otherwise, it -creates a new `TokenAndRefCount`. - -The `TokenAndRefCount` stores a `Token` that can be used to link asynchronous `Threads` together and tracks the number of incoming references to the `Token`. -When `TokenAwareRunnable.run()` is invoked the stored `Token` is linked on the executing `Thread` and finally the `Token` is expired when `run()` completes, -allowing the `Transaction` to complete. - -### Case 2: Parallelism - -In this case a `TokenDelegateExecutor` is initialized and used to wrap the `Executor` argument that was passed to `execAsync`. When -`TokenDelegateExecutor.execute(Runnable runnable)` is invoked it will initialize and store a `TokenAwareRunnable` that wraps the `CompletableFuture$Async` -argument passed to `execAsync`. From this point on, the `TokenAwareRunnable` functions exactly as described in Case 1: No Parallelism. - -## Logging - -This instrumentation will produce entries such as the following when searching the logs for keywords `token info`: - -``` -2022-01-07T17:22:03,481-0800 [53655 270] com.newrelic FINEST: [Empty token]: token info TokenAwareRunnable token info set -2022-01-07T17:22:03,482-0800 [53655 270] com.newrelic FINEST: [Empty token]: token info Token info set in thread -2022-01-07T17:22:03,482-0800 [53655 270] com.newrelic FINEST: [Empty token]: token info Clearing token info from thread -``` - -## Testing - -See the following functional tests: `newrelic-java-agent/functional_test/src/test/java/test/newrelic/test/agent/CompletableFutureTest.java` \ No newline at end of file diff --git a/instrumentation/java.completable-future-jdk8/build.gradle b/instrumentation/java.completable-future-jdk8/build.gradle deleted file mode 100644 index 1f25baa32b..0000000000 --- a/instrumentation/java.completable-future-jdk8/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -dependencies { - implementation(project(":agent-bridge")) -} - -// This instrumentation module should not use the bootstrap classpath - - -jar { - manifest { attributes 'Implementation-Title': 'com.newrelic.instrumentation.java.completable-future-jdk8' } -} - -verifyInstrumentation { - verifyClasspath = false // We don't want to verify classpath since these are JDK classes -} - -site { - title 'Java Completable futures' - type 'Other' - versionOverride '[8,)' -} diff --git a/instrumentation/java.completable-future-jdk8/src/main/java/java/util/concurrent/CompletableFuture_Instrumentation.java b/instrumentation/java.completable-future-jdk8/src/main/java/java/util/concurrent/CompletableFuture_Instrumentation.java deleted file mode 100644 index 500668883e..0000000000 --- a/instrumentation/java.completable-future-jdk8/src/main/java/java/util/concurrent/CompletableFuture_Instrumentation.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package java.util.concurrent; - -import com.newrelic.api.agent.weaver.MatchType; -import com.newrelic.api.agent.weaver.Weave; -import util.TokenAwareRunnable; -import util.TokenDelegateExecutor; - -@Weave(type = MatchType.ExactClass, originalName = "java.util.concurrent.CompletableFuture") -public class CompletableFuture_Instrumentation { - - @Weave(type = MatchType.BaseClass, originalName = "java.util.concurrent.CompletableFuture$Async") - abstract static class Async extends ForkJoinTask - implements Runnable, CompletableFuture.AsynchronousCompletionTask { - public final Void getRawResult() { - return null; - } - - public final void setRawResult(Void v) { - } - - public final void run() { - exec(); - } - } - - private static boolean noParallelism(Executor e) { - return (e == ForkJoinPool.commonPool() && - ForkJoinPool.getCommonPoolParallelism() <= 1); - } - - private static Executor useTokenDelegateExecutor(Executor e) { - if (null == e || e instanceof TokenDelegateExecutor) { - return e; - } else { - return new TokenDelegateExecutor(e); - } - } - - static void execAsync(Executor e, CompletableFuture_Instrumentation.Async r) { - if (noParallelism(e)) { - new Thread(new TokenAwareRunnable(r)).start(); - } else { - Executor tde = useTokenDelegateExecutor(e); - if (null != tde) { - tde.execute(r); - } - } - } - -} diff --git a/instrumentation/java.completable-future-jdk8/src/main/java/util/TokenAndRefUtils.java b/instrumentation/java.completable-future-jdk8/src/main/java/util/TokenAndRefUtils.java deleted file mode 100644 index 0be21eb5e4..0000000000 --- a/instrumentation/java.completable-future-jdk8/src/main/java/util/TokenAndRefUtils.java +++ /dev/null @@ -1,63 +0,0 @@ -package util; - -import com.newrelic.agent.bridge.AgentBridge; -import com.newrelic.agent.bridge.Transaction; - -import java.text.MessageFormat; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.logging.Level; - -public class TokenAndRefUtils { - - public static AgentBridge.TokenAndRefCount getThreadTokenAndRefCount() { - AgentBridge.TokenAndRefCount tokenAndRefCount = AgentBridge.activeToken.get(); - if (tokenAndRefCount == null) { - Transaction tx = AgentBridge.getAgent().getTransaction(false); - if (tx != null) { - tokenAndRefCount = new AgentBridge.TokenAndRefCount(tx.getToken(), - AgentBridge.getAgent().getTracedMethod(), new AtomicInteger(1)); - } - } else { - tokenAndRefCount.refCount.incrementAndGet(); - } - return tokenAndRefCount; - } - - public static Transaction getTransaction(AgentBridge.TokenAndRefCount tokenAndRefCount) { - if(tokenAndRefCount != null && tokenAndRefCount.token != null) { - return (Transaction) tokenAndRefCount.token.getTransaction(); - } else { - return null; - } - } - - public static void setThreadTokenAndRefCount(AgentBridge.TokenAndRefCount tokenAndRefCount, Transaction transaction) { - if (tokenAndRefCount != null && tokenAndRefCount.token != null) { - AgentBridge.activeToken.set(tokenAndRefCount); - tokenAndRefCount.token.link(); - } else if(tokenAndRefCount != null && transaction != null) { - tokenAndRefCount.token = transaction.getToken(); - tokenAndRefCount.token.link(); - tokenAndRefCount.refCount = new AtomicInteger(1); - } - } - - public static void clearThreadTokenAndRefCountAndTxn(AgentBridge.TokenAndRefCount tokenAndRefCount) { - AgentBridge.activeToken.remove(); - if (tokenAndRefCount != null && tokenAndRefCount.refCount.decrementAndGet() == 0) { - tokenAndRefCount.token.expire(); - tokenAndRefCount.token = null; - } - } - - public static void logTokenInfo(AgentBridge.TokenAndRefCount tokenAndRefCount, String msg) { - if (AgentBridge.getAgent().getLogger().isLoggable(Level.FINEST)) { - String tokenMsg = (tokenAndRefCount != null && tokenAndRefCount.token != null) - ? String.format("[%s:%s:%d]", tokenAndRefCount.token, tokenAndRefCount.token.getTransaction(), - tokenAndRefCount.refCount.get()) - : "[Empty token]"; - AgentBridge.getAgent().getLogger().log(Level.FINEST, MessageFormat.format("{0}: token info {1}", tokenMsg, msg)); - } - } - -} diff --git a/instrumentation/java.completable-future-jdk8/src/main/java/util/TokenAwareRunnable.java b/instrumentation/java.completable-future-jdk8/src/main/java/util/TokenAwareRunnable.java deleted file mode 100644 index 82b81afabd..0000000000 --- a/instrumentation/java.completable-future-jdk8/src/main/java/util/TokenAwareRunnable.java +++ /dev/null @@ -1,35 +0,0 @@ -package util; - -import com.newrelic.agent.bridge.AgentBridge; -import com.newrelic.agent.bridge.Transaction; - -import static util.TokenAndRefUtils.*; - -public final class TokenAwareRunnable implements Runnable { - private final Runnable delegate; - - private AgentBridge.TokenAndRefCount tokenAndRefCount; - private Transaction transaction; - - public TokenAwareRunnable(Runnable delegate) { - this.delegate = delegate; - //get token state from calling Thread - this.tokenAndRefCount = getThreadTokenAndRefCount(); - this.transaction = getTransaction(tokenAndRefCount); - logTokenInfo(tokenAndRefCount, "TokenAwareRunnable token info set"); - } - - @Override - public void run() { - try { - if (delegate != null) { - logTokenInfo(tokenAndRefCount, "Token info set in thread"); - setThreadTokenAndRefCount(tokenAndRefCount, transaction); - delegate.run(); - } - } finally { - logTokenInfo(tokenAndRefCount, "Clearing token info from thread "); - clearThreadTokenAndRefCountAndTxn(tokenAndRefCount); - } - } -} diff --git a/instrumentation/java.completable-future-jdk8/src/main/java/util/TokenDelegateExecutor.java b/instrumentation/java.completable-future-jdk8/src/main/java/util/TokenDelegateExecutor.java deleted file mode 100644 index ab16289a1e..0000000000 --- a/instrumentation/java.completable-future-jdk8/src/main/java/util/TokenDelegateExecutor.java +++ /dev/null @@ -1,17 +0,0 @@ -package util; - -import java.util.concurrent.Executor; - -public class TokenDelegateExecutor implements Executor { - public final Executor delegate; - - public TokenDelegateExecutor(final Executor delegate) { - this.delegate = delegate; - } - - @Override - public void execute(Runnable runnable) { - runnable = new TokenAwareRunnable(runnable); - delegate.execute(runnable); - } -} diff --git a/instrumentation/netty-3.4/build.gradle b/instrumentation/netty-3.4/build.gradle deleted file mode 100644 index 252813cd0b..0000000000 --- a/instrumentation/netty-3.4/build.gradle +++ /dev/null @@ -1,18 +0,0 @@ -dependencies { - implementation(project(":agent-bridge")) - implementation("io.netty:netty:3.4.0.Final") -} - -jar { - manifest { attributes 'Implementation-Title': 'com.newrelic.instrumentation.netty-3.4', - 'Implementation-Title-Alias': 'netty_instrumentation' } -} - -verifyInstrumentation { - passesOnly 'io.netty:netty:[3.3.0.Alpha1,3.8.0.Final)' -} - -site { - title 'Netty' - type 'Appserver' -} \ No newline at end of file diff --git a/instrumentation/netty-3.4/src/main/java/com/agent/instrumentation/netty34/NettyUtil.java b/instrumentation/netty-3.4/src/main/java/com/agent/instrumentation/netty34/NettyUtil.java deleted file mode 100644 index 0182327543..0000000000 --- a/instrumentation/netty-3.4/src/main/java/com/agent/instrumentation/netty34/NettyUtil.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.agent.instrumentation.netty34; - -import java.net.InetSocketAddress; -import java.net.SocketAddress; -import java.util.logging.Level; - -import com.newrelic.agent.bridge.AgentBridge; -import com.newrelic.agent.bridge.Token; -import com.newrelic.api.agent.NewRelic; -import org.jboss.netty.handler.codec.http.DefaultHttpResponse; -import org.jboss.netty.util.Version; - -public abstract class NettyUtil { - - public static String getNettyVersion() { - return Version.ID; - } - - public static void setAppServerPort(SocketAddress localAddress) { - if (localAddress instanceof InetSocketAddress) { - int port = ((InetSocketAddress) localAddress).getPort(); - NewRelic.setAppServerPort(port); - } else { - AgentBridge.getAgent().getLogger().log(Level.FINE, "Unable to get Netty port number"); - } - } - - public static void setServerInfo() { - AgentBridge.publicApi.setServerInfo("Netty", getNettyVersion()); - } - - public static boolean processResponse(Object msg, Token token) { - if (token != null) { - if (msg instanceof DefaultHttpResponse) { - com.newrelic.api.agent.Transaction tx = token.getTransaction(); - if (tx != null) { - try { - tx.setWebResponse(new ResponseWrapper((DefaultHttpResponse) msg)); - tx.addOutboundResponseHeaders(); - tx.markResponseSent(); - } catch (Exception e) { - AgentBridge.getAgent().getLogger().log(Level.FINER, e, "Unable to set web request on transaction: {0}", tx); - } - } - token.expire(); - return true; - } - } - return false; - } - -} diff --git a/instrumentation/netty-3.4/src/main/java/com/agent/instrumentation/netty34/RequestWrapper.java b/instrumentation/netty-3.4/src/main/java/com/agent/instrumentation/netty34/RequestWrapper.java deleted file mode 100644 index 37595db05e..0000000000 --- a/instrumentation/netty-3.4/src/main/java/com/agent/instrumentation/netty34/RequestWrapper.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.agent.instrumentation.netty34; - -import com.newrelic.agent.bridge.AgentBridge; -import com.newrelic.api.agent.ExtendedRequest; -import com.newrelic.api.agent.HeaderType; -import com.newrelic.api.agent.Request; -import org.jboss.netty.handler.codec.http.Cookie; -import org.jboss.netty.handler.codec.http.CookieDecoder; -import org.jboss.netty.handler.codec.http.DefaultHttpRequest; -import org.jboss.netty.handler.codec.http.HttpHeaders; -import org.jboss.netty.handler.codec.http.HttpRequest; -import org.jboss.netty.handler.codec.http.QueryStringDecoder; - -import java.util.Collections; -import java.util.Enumeration; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.logging.Level; -import java.util.regex.Pattern; - -public class RequestWrapper extends ExtendedRequest { - private static final Pattern URL_REPLACEMENT_PATTERN = Pattern.compile("(?i)%(?![\\da-f]{2})"); - private static CookieDecoder cookieDecoder = new CookieDecoder(); - private final HttpRequest request; - private final Set cookies; - private final Map> parameters; - - public RequestWrapper(DefaultHttpRequest request) { - super(); - this.request = request; - - Set rawCookies = null; - if (request.getHeaderNames().contains(HttpHeaders.Names.COOKIE)) { - try { - rawCookies = cookieDecoder.decode(request.getHeader(HttpHeaders.Names.COOKIE)); - } catch (Exception e) { - AgentBridge.getAgent().getLogger().log(Level.FINER, e, "Unable to decode cookie: {0}", - request.getHeader(HttpHeaders.Names.COOKIE)); - rawCookies = Collections.emptySet(); - } - } - this.cookies = rawCookies; - - Map> params; - try { - String uri = request.getUri(); - uri = URL_REPLACEMENT_PATTERN.matcher(uri).replaceAll("%25"); // Escape any percent signs in the URI - QueryStringDecoder decoderQuery = new QueryStringDecoder(uri); - params = decoderQuery.getParameters(); - } catch (Exception e) { - AgentBridge.getAgent().getLogger().log(Level.FINER, e, "Unable to decode URI: {0}", request.getUri()); - params = new LinkedHashMap<>(); - } - this.parameters = params; - } - - @Override - public String getRequestURI() { - return request.getUri(); - } - - @Override - public String getHeader(String name) { - return request.getHeader(name); - } - - @Override - public String getRemoteUser() { - return null; - } - - @SuppressWarnings("rawtypes") - @Override - public Enumeration getParameterNames() { - return Collections.enumeration(parameters.keySet()); - } - - @Override - public String[] getParameterValues(String name) { - List result = parameters.get(name); - return (result == null ? null : result.toArray(new String[0])); - } - - @Override - public Object getAttribute(String name) { - return null; - } - - @Override - public String getCookieValue(String name) { - for (Cookie cookie : cookies) { - if (cookie.getName().equals(name)) { - return cookie.getValue(); - } - } - return null; - } - - @Override - public HeaderType getHeaderType() { - return HeaderType.HTTP; - } - - @Override - public String getMethod() { - return request.getMethod().toString(); - } - - @Override - public List getHeaders(String name) { - return request.getHeaders(name); - } -} diff --git a/instrumentation/netty-3.4/src/main/java/com/agent/instrumentation/netty34/ResponseWrapper.java b/instrumentation/netty-3.4/src/main/java/com/agent/instrumentation/netty34/ResponseWrapper.java deleted file mode 100644 index 84b797c01a..0000000000 --- a/instrumentation/netty-3.4/src/main/java/com/agent/instrumentation/netty34/ResponseWrapper.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.agent.instrumentation.netty34; - -import com.newrelic.api.agent.ExtendedResponse; -import org.jboss.netty.handler.codec.http.DefaultHttpResponse; -import org.jboss.netty.handler.codec.http.HttpHeaders; - -import com.newrelic.api.agent.HeaderType; -import com.newrelic.api.agent.Response; - -public class ResponseWrapper extends ExtendedResponse { - private final DefaultHttpResponse response; - - public ResponseWrapper(DefaultHttpResponse msg) { - this.response = msg; - } - - @Override - public HeaderType getHeaderType() { - return HeaderType.HTTP; - } - - @Override - public void setHeader(String name, String value) { - response.setHeader(name, value); - } - - @Override - public int getStatus() throws Exception { - return response.getStatus().getCode(); - } - - @Override - public String getStatusMessage() throws Exception { - return response.getStatus().getReasonPhrase(); - } - - @Override - public String getContentType() { - return response.getHeader(HttpHeaders.Names.CONTENT_TYPE); - } - - @Override - public long getContentLength() { - return response.getContentLength(); - } -} diff --git a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/bootstrap/NettyDispatcher.java b/instrumentation/netty-3.4/src/main/java/org/jboss/netty/bootstrap/NettyDispatcher.java deleted file mode 100644 index 900d994adf..0000000000 --- a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/bootstrap/NettyDispatcher.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package org.jboss.netty.bootstrap; - -import java.util.logging.Level; - -import com.agent.instrumentation.netty34.RequestWrapper; -import com.newrelic.agent.bridge.AgentBridge; -import com.newrelic.agent.bridge.Transaction; -import com.newrelic.agent.bridge.TransactionNamePriority; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.TracedMethod; -import com.newrelic.api.agent.weaver.Weaver; -import com.newrelic.api.agent.weaver.internal.WeavePackageType; -import org.jboss.netty.channel.ChannelHandlerContext_Instrumentation; -import org.jboss.netty.handler.codec.http.DefaultHttpRequest; - -/** - * This isn't a netty class. This is an agent ChannelUpstreamHandler which will start a transaction on i/o read. It's - * best to put this handler in front of "interesting" (e.g. ServerBootstrap) pipelines. - * - * Since this class creates a tracer, its class+method name will show in the TT, hence the class name. - */ -public class NettyDispatcher { - - private static volatile NettyDispatcher instance = null; - - public static NettyDispatcher get() { - if (null == instance) { - synchronized (NettyDispatcher.class) { - if (null == instance) { - instance = new NettyDispatcher(); - } - } - } - return instance; - } - - private NettyDispatcher() { - AgentBridge.instrumentation.retransformUninstrumentedClass(NettyDispatcher.class); - } - - @Trace(dispatcher = true) - public static void upstreamDispatcher(ChannelHandlerContext_Instrumentation ctx, Object msg) { - try { - ctx.getPipeline().token = AgentBridge.getAgent().getTransaction().getToken(); - - TracedMethod tracer = AgentBridge.getAgent().getTransaction().getTracedMethod(); - if (tracer == null) { - AgentBridge.getAgent().getLogger().log(Level.FINEST, "Unable to dispatch netty tx. No tracer."); // it happens. - } else { - tracer.setMetricName("NettyUpstreamDispatcher"); - AgentBridge.currentApiSource.set(WeavePackageType.INTERNAL); - AgentBridge.getAgent().getTransaction().setTransactionName(TransactionNamePriority.SERVLET_NAME, true, - "NettyDispatcher", "NettyDispatcher"); - } - - Transaction tx = AgentBridge.getAgent().getTransaction(false); - if (tx != null) { - tx.setWebRequest(new RequestWrapper((DefaultHttpRequest) msg)); - } - - } catch(Throwable t) { - AgentBridge.instrumentation.noticeInstrumentationError(t, Weaver.getImplementationTitle()); - } finally { - AgentBridge.currentApiSource.remove(); - } - } - -} diff --git a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/bootstrap/ServerBootstrap.java b/instrumentation/netty-3.4/src/main/java/org/jboss/netty/bootstrap/ServerBootstrap.java deleted file mode 100644 index 250d4aba42..0000000000 --- a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/bootstrap/ServerBootstrap.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package org.jboss.netty.bootstrap; - -import com.agent.instrumentation.netty34.NettyUtil; -import com.newrelic.agent.bridge.AgentBridge; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelPipeline; -import org.jboss.netty.channel.ChannelPipelineFactory; - -import java.net.SocketAddress; -import java.util.logging.Level; - -@Weave -public abstract class ServerBootstrap extends Bootstrap { - - public Channel bind(final SocketAddress localAddress) { - NettyUtil.setAppServerPort(localAddress); - NettyUtil.setServerInfo(); - - // initialize NettyDispatcher here to avoid classloader deadlocks - NettyDispatcher.get(); - - return Weaver.callOriginal(); - } - -} diff --git a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/channel/ChannelHandlerContext_Instrumentation.java b/instrumentation/netty-3.4/src/main/java/org/jboss/netty/channel/ChannelHandlerContext_Instrumentation.java deleted file mode 100644 index 75b0779d33..0000000000 --- a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/channel/ChannelHandlerContext_Instrumentation.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package org.jboss.netty.channel; - -import com.newrelic.api.agent.weaver.MatchType; -import com.newrelic.api.agent.weaver.Weave; - -@Weave(type = MatchType.Interface, originalName = "org.jboss.netty.channel.ChannelHandlerContext") -public abstract class ChannelHandlerContext_Instrumentation { - - public abstract ChannelPipeline_Instrumentation getPipeline(); - -} diff --git a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/channel/ChannelPipeline_Instrumentation.java b/instrumentation/netty-3.4/src/main/java/org/jboss/netty/channel/ChannelPipeline_Instrumentation.java deleted file mode 100644 index 702b10b3fb..0000000000 --- a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/channel/ChannelPipeline_Instrumentation.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package org.jboss.netty.channel; - -import com.newrelic.agent.bridge.Token; -import com.newrelic.api.agent.weaver.MatchType; -import com.newrelic.api.agent.weaver.NewField; -import com.newrelic.api.agent.weaver.Weave; - -@Weave(type = MatchType.BaseClass, originalName = "org.jboss.netty.channel.ChannelPipeline") -public class ChannelPipeline_Instrumentation { - - @NewField - public Token token; - -} diff --git a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/channel/ChannelUpstreamHandler_Instrumentation.java b/instrumentation/netty-3.4/src/main/java/org/jboss/netty/channel/ChannelUpstreamHandler_Instrumentation.java deleted file mode 100644 index 7b0087eb95..0000000000 --- a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/channel/ChannelUpstreamHandler_Instrumentation.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package org.jboss.netty.channel; - -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.Interface, originalName = "org.jboss.netty.channel.ChannelUpstreamHandler") -public abstract class ChannelUpstreamHandler_Instrumentation { - - @Trace(async = true, excludeFromTransactionTrace = true) - public void handleUpstream(ChannelHandlerContext_Instrumentation ctx, ChannelEvent e) throws Exception { - if (ctx.getPipeline().token != null) { - ctx.getPipeline().token.link(); - } - - Weaver.callOriginal(); - } - -} diff --git a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpHeaders.java b/instrumentation/netty-3.4/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpHeaders.java deleted file mode 100644 index f72c313b26..0000000000 --- a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpHeaders.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package org.jboss.netty.handler.codec.http; - -import com.newrelic.api.agent.weaver.SkipIfPresent; - -/** - * Prevent netty-3.4 from loading with 3.8 - */ -@SkipIfPresent -public class DefaultHttpHeaders { -} \ No newline at end of file diff --git a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java b/instrumentation/netty-3.4/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java deleted file mode 100644 index 97daeeee2b..0000000000 --- a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageDecoder.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package org.jboss.netty.handler.codec.http; - -import org.jboss.netty.bootstrap.NettyDispatcher; -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelHandlerContext; -import org.jboss.netty.channel.ChannelHandlerContext_Instrumentation; - -import com.agent.instrumentation.netty34.NettyUtil; -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 class HttpMessageDecoder { - @Trace - protected Object decode(ChannelHandlerContext_Instrumentation ctx, Channel channel, ChannelBuffer buffer, State state) { - Object request = Weaver.callOriginal(); - if (request instanceof HttpRequest && ctx.getPipeline().token == null) { - NettyDispatcher.upstreamDispatcher(ctx, request); - } - return request; - } - - @Weave - protected static class State { - } -} diff --git a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageEncoder.java b/instrumentation/netty-3.4/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageEncoder.java deleted file mode 100644 index 4768b9c520..0000000000 --- a/instrumentation/netty-3.4/src/main/java/org/jboss/netty/handler/codec/http/HttpMessageEncoder.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package org.jboss.netty.handler.codec.http; - -import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelHandlerContext; -import org.jboss.netty.channel.ChannelHandlerContext_Instrumentation; - -import com.agent.instrumentation.netty34.NettyUtil; -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 class HttpMessageEncoder { - @Trace - protected Object encode(ChannelHandlerContext_Instrumentation ctx, Channel channel, Object msg) { - boolean expired = NettyUtil.processResponse(msg, ctx.getPipeline().token); - if (expired) { - ctx.getPipeline().token = null; - } - return Weaver.callOriginal(); - } - -} diff --git a/instrumentation/netty-3.4/src/test/java/netty34/RequestWrapperTest.java b/instrumentation/netty-3.4/src/test/java/netty34/RequestWrapperTest.java deleted file mode 100644 index 99edc986c4..0000000000 --- a/instrumentation/netty-3.4/src/test/java/netty34/RequestWrapperTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package netty34; - -import com.agent.instrumentation.netty34.RequestWrapper; -import org.jboss.netty.handler.codec.http.DefaultHttpRequest; -import org.junit.Assert; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class RequestWrapperTest { - - @Test - public void testPercentageEscaping() { - Map inputExpectedMap = new HashMap<>(); - inputExpectedMap.put("http://example.com?asdf=%qwer", "%qwer"); - inputExpectedMap.put("http://example.com?asdf=%20", " "); - inputExpectedMap.put("http://example.com?asdf=%2b", "+"); - inputExpectedMap.put("http://example.com?asdf=qwer", "qwer"); - - for (Map.Entry inputExpectedEntry : inputExpectedMap.entrySet()) { - String input = inputExpectedEntry.getKey(); - String expected = inputExpectedEntry.getValue(); - DefaultHttpRequest request = mock(DefaultHttpRequest.class); - when(request.getUri()).thenReturn(input); - RequestWrapper requestWrapper = new RequestWrapper(request); - Assert.assertEquals(expected, requestWrapper.getParameterValues("asdf")[0]); - } - } -} \ No newline at end of file diff --git a/instrumentation/play-2.3/build.gradle b/instrumentation/play-2.3/build.gradle deleted file mode 100644 index 9b95650ae7..0000000000 --- a/instrumentation/play-2.3/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -apply plugin: 'scala' - -isScalaProjectEnabled(project, "scala-2.10") - -repositories { - maven { - url 'https://repo.typesafe.com/typesafe/maven-releases/' - } -} - -dependencies { - implementation(project(":agent-bridge")) - implementation(project(":newrelic-weaver-api")) - implementation("com.typesafe.play:play_2.10:2.3.10") - implementation("org.scala-lang:scala-library:2.10.7") -} - -jar { - manifest { attributes 'Implementation-Title': 'com.newrelic.instrumentation.play-2.3', - 'Implementation-Title-Alias': 'play2_instrumentation' } -} - -verifyInstrumentation { - // compiled with scala 2.10 - passes 'com.typesafe.play:play_2.10:[2.3.0,2.4.0-M1)' - fails 'com.typesafe.play:play_2.10:2.2.0' - // compiled with scala 2.11 - passes 'com.typesafe.play:play_2.11:[2.3.0,2.4.0-M1)' - // some random snapshot - exclude 'com.typesafe.play:play_2.10:2.3-20131213005945Z' - // build snapshots - excludeRegex '.*-[a-z0-9]{38}[a-z0-9]*$' - excludeRegex '.*-RC[0-9]+$' -} - -site { - title 'Play' - type 'Appserver' -} \ No newline at end of file diff --git a/instrumentation/play-2.3/src/main/scala/play/api/mvc/Action.scala b/instrumentation/play-2.3/src/main/scala/play/api/mvc/Action.scala deleted file mode 100644 index 2723b5538b..0000000000 --- a/instrumentation/play-2.3/src/main/scala/play/api/mvc/Action.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package play.api.mvc - -import com.newrelic.api.agent.weaver.{MatchType,Weave,Weaver}; -import com.newrelic.api.agent.Trace; -import com.newrelic.agent.bridge.AgentBridge; -import com.newrelic.agent.bridge.TracedMethod; -import java.util.logging.Level; -import scala.concurrent._; - -import play.api.mvc.Request; - -@Weave(`type` = MatchType.Interface) -class Action[A] { - @Trace(metricName = "Play2Controller") - def apply(request: Request[A]): Future[Result] = { - return Weaver.callOriginal(); - } -} diff --git a/instrumentation/play-2.3/src/main/scala/play/core/router/Router.scala b/instrumentation/play-2.3/src/main/scala/play/core/router/Router.scala deleted file mode 100644 index c92ab09762..0000000000 --- a/instrumentation/play-2.3/src/main/scala/play/core/router/Router.scala +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package play.core - -import com.newrelic.api.agent.weaver.{MatchType,Weave,Weaver}; -import com.newrelic.agent.bridge.AgentBridge; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.TransactionNamePriority; -import java.util.logging.Level; - -import play.api.mvc.Handler; -import play.core.Router.HandlerDef; -import play.core.Router.HandlerInvokerFactory; -import play.core.Router.HandlerInvoker; - -/** - * Routes is nested in the Router class. - * However, the weaver thinks we're trying to match non-static classes if we express that in our instrumentation. - */ -@Weave(`type` = MatchType.Interface) -class Router$Routes { - def createInvoker[T](fakeCall: => T, handlerDef: HandlerDef)(implicit hif: HandlerInvokerFactory[T]): HandlerInvoker[T] = { - return new NewRelicWrapperInvoker(Weaver.callOriginal(), handlerDef) - } -} - -//Util classes - -class NewRelicWrapperInvoker[A](underlyingInvoker: HandlerInvoker[A], handlerDef: HandlerDef) extends HandlerInvoker[A] { - val PLAY_CONTROLLER_ACTION: String = "PlayControllerAction" - val txName = handlerDef.controller + "." + handlerDef.method - def call(call: => A): Handler = { - try { - AgentBridge.getAgent.getLogger.log(Level.FINE, "Setting transaction name to \"{0}\" using Play 2.3 controller action", txName); - AgentBridge.getAgent.getTransaction.setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, true, PLAY_CONTROLLER_ACTION, txName); - } catch { - case t: Throwable => AgentBridge.instrumentation.noticeInstrumentationError(t, Weaver.getImplementationTitle()); - } - return underlyingInvoker.call(call); - } -} diff --git a/instrumentation/play-2.3/src/main/scala/play/core/server/Server.scala b/instrumentation/play-2.3/src/main/scala/play/core/server/Server.scala deleted file mode 100644 index 9fe98be5eb..0000000000 --- a/instrumentation/play-2.3/src/main/scala/play/core/server/Server.scala +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package play.core.server - -import com.newrelic.agent.bridge.{AgentBridge, TracedMethod} -import com.newrelic.api.agent.Trace -import com.newrelic.api.agent.weaver.{MatchType, Weave, Weaver} -import play.api.mvc.{Handler, RequestHeader, Result} - -import scala.concurrent.Future - - -@Weave(`type` = MatchType.Interface) -class Server { - @Trace(dispatcher = true) - def getHandlerFor(request: RequestHeader): Either[Future[Result], (RequestHeader, Handler, Application)] = { - val result: Either[Future[Result], (RequestHeader, Handler, Application)] = Weaver.callOriginal() - val tracer = AgentBridge.getAgent.getTransaction.getTracedMethod - if (tracer != null) { - tracer.setMetricName("Play2Routing") - } - - result - } -} diff --git a/instrumentation/spring-3.0.0/build.gradle b/instrumentation/spring-3.0.0/build.gradle deleted file mode 100644 index e8f845effc..0000000000 --- a/instrumentation/spring-3.0.0/build.gradle +++ /dev/null @@ -1,28 +0,0 @@ -plugins { - id "org.jetbrains.kotlin.jvm" -} - -dependencies { - implementation(project(":agent-bridge")) - implementation("org.springframework:spring-context:3.0.0.RELEASE") - implementation("org.springframework:spring-web:3.0.0.RELEASE") - testImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.21") -} - -jar { - manifest { attributes 'Implementation-Title': 'com.newrelic.instrumentation.spring-3.0.0', - 'Implementation-Title-Alias': 'spring_annotations'} -} - -verifyInstrumentation { - passesOnly 'org.springframework:spring-web:[3.0.0.RELEASE,4.0.0)' - - // There is a random 2.5 version that passes, lets ignore it - exclude 'org.springframework:spring-web:[0,2.5]' - excludeRegex 'org.springframework:spring-web:.*(RC|SEC|M)[0-9]*$' -} - -site { - title 'Spring' - type 'Framework' -} \ No newline at end of file diff --git a/instrumentation/spring-3.0.0/src/main/java/com/nr/agent/instrumentation/EventListener_Skip.java b/instrumentation/spring-3.0.0/src/main/java/com/nr/agent/instrumentation/EventListener_Skip.java deleted file mode 100644 index c471ed4984..0000000000 --- a/instrumentation/spring-3.0.0/src/main/java/com/nr/agent/instrumentation/EventListener_Skip.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.nr.agent.instrumentation; - -import com.newrelic.api.agent.weaver.SkipIfPresent; - -/** - * This class is present in Spring 4.2.0 >= - */ -@SkipIfPresent(originalName = "org.springframework.context.event.EventListener") -public class EventListener_Skip { -} diff --git a/instrumentation/spring-3.0.0/src/main/java/com/nr/agent/instrumentation/RestController_Skip.java b/instrumentation/spring-3.0.0/src/main/java/com/nr/agent/instrumentation/RestController_Skip.java deleted file mode 100644 index 7a0b19ec9c..0000000000 --- a/instrumentation/spring-3.0.0/src/main/java/com/nr/agent/instrumentation/RestController_Skip.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.nr.agent.instrumentation; - -import com.newrelic.api.agent.weaver.SkipIfPresent; - -/** - * This class is present in Spring 4.0.0 >= - */ -@SkipIfPresent(originalName = "org.springframework.web.bind.annotation.RestController") -public class RestController_Skip { -} - - diff --git a/instrumentation/spring-3.0.0/src/main/java/com/nr/agent/instrumentation/SpringControllerUtility.java b/instrumentation/spring-3.0.0/src/main/java/com/nr/agent/instrumentation/SpringControllerUtility.java deleted file mode 100644 index 0b77f53213..0000000000 --- a/instrumentation/spring-3.0.0/src/main/java/com/nr/agent/instrumentation/SpringControllerUtility.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.nr.agent.instrumentation; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -public class SpringControllerUtility { - - public static String getPath(String rootPath, String methodPath, RequestMethod httpMethod) { - StringBuilder fullPath = new StringBuilder(); - if (rootPath != null && !rootPath.isEmpty()) { - if (rootPath.endsWith("/")) { - fullPath.append(rootPath.substring(0, rootPath.length() - 1)); - } else { - fullPath.append(rootPath); - } - } - - if (methodPath != null && !methodPath.isEmpty()) { - if (!methodPath.startsWith("/")) { - fullPath.append('/'); - } - if (methodPath.endsWith("/")) { - fullPath.append(methodPath.substring(0, methodPath.length() - 1)); - } else { - fullPath.append(methodPath); - } - } - - if (httpMethod != null) { - fullPath.append(" (").append(httpMethod.name()).append(')'); - } - - return fullPath.toString(); - } - - /** - * Finds request mapping path. - * - * @param annotation request mapping - * @return path or null if not found. - */ - public static String getPathValue(RequestMapping annotation) { - String result = null; - if (annotation != null) { - String[] values = annotation.value(); - if (values.length > 0 && !values[0].contains("error.path")) { - result = values[0]; - } - } - - return result; - } - -} diff --git a/instrumentation/spring-3.0.0/src/main/java/com/nr/agent/instrumentation/SpringController_Instrumentation.java b/instrumentation/spring-3.0.0/src/main/java/com/nr/agent/instrumentation/SpringController_Instrumentation.java deleted file mode 100644 index 1d904b84a7..0000000000 --- a/instrumentation/spring-3.0.0/src/main/java/com/nr/agent/instrumentation/SpringController_Instrumentation.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.nr.agent.instrumentation; - -import java.lang.invoke.MethodHandles; -import java.util.logging.Level; - -import com.newrelic.agent.bridge.Transaction; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import com.newrelic.agent.bridge.AgentBridge; -import com.newrelic.agent.bridge.TransactionNamePriority; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.weaver.MatchType; -import com.newrelic.api.agent.weaver.WeaveIntoAllMethods; -import com.newrelic.api.agent.weaver.WeaveWithAnnotation; -import com.newrelic.api.agent.weaver.Weaver; - -@WeaveWithAnnotation(annotationClasses = {"org.springframework.stereotype.Controller"}, type = MatchType.ExactClass) -public class SpringController_Instrumentation { - - @WeaveWithAnnotation(annotationClasses = { "org.springframework.web.bind.annotation.RequestMapping" }) - @WeaveIntoAllMethods - @Trace - private static void instrumentation() { - Transaction transaction = AgentBridge.getAgent().getTransaction(false); - if (transaction != null) { - RequestMapping rootPathMapping = Weaver.getClassAnnotation(RequestMapping.class); - RequestMapping methodPathMapping = Weaver.getMethodAnnotation(RequestMapping.class); - - String rootPath = SpringControllerUtility.getPathValue(rootPathMapping); - String methodPath = SpringControllerUtility.getPathValue(methodPathMapping); - - RequestMethod httpMethod = RequestMethod.GET; - RequestMethod[] methods = methodPathMapping.method(); - if (methods.length > 0) { - httpMethod = methods[0]; - } - - if (rootPath == null && methodPath == null) { - AgentBridge.getAgent().getLogger().log(Level.FINE, "No path was specified for SpringController {0}", - MethodHandles.lookup().lookupClass().getName()); - } else { - String fullPath = SpringControllerUtility.getPath(rootPath, methodPath, httpMethod); - transaction.setTransactionName(TransactionNamePriority.FRAMEWORK_HIGH, true, "SpringController", fullPath); - } - } - } - -} diff --git a/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/App.java b/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/App.java deleted file mode 100644 index a415c7f2bc..0000000000 --- a/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/App.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.nr.agent.instrumentation; - -import java.util.Collections; - -import com.newrelic.api.agent.Trace; - -public class App { - - @Trace(dispatcher = true) - public static void error() { - try { - ErrorPath path = new ErrorPath(); - path.testError(); - } - catch( RuntimeException caught) { - System.out.printf("Caught exception"); - } - } - - @Trace(dispatcher = true) - public static String pathClass() { - return new PathClass().testPath(); - } - - @Trace(dispatcher = true) - public static String innerPath() { - return new TestInnerAndDefaultPath().testInnerPath(); - } - - @Trace(dispatcher = true) - public static String methodPath() { - return new TestPathAnnotationForMethod().testPathAnnotation(); - } - - @Trace(dispatcher = true) - public static String kotlinDefaultParameter() { - return new KotlinSpringClass().read(Collections.emptyList(), 10); - } -} diff --git a/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/ErrorPath.java b/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/ErrorPath.java deleted file mode 100644 index e7f78d0a56..0000000000 --- a/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/ErrorPath.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.nr.agent.instrumentation; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -@Controller -public class ErrorPath { - - @RequestMapping(value = "/errorPath", method = RequestMethod.GET) - public Object testError() { - System.out.printf("throwing exception"); - throw new RuntimeException("test"); - } - - @RequestMapping(value = "/error.pathBad") - @ExceptionHandler(RuntimeException.class) - public void conflict() { - } -} diff --git a/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/PathClass.java b/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/PathClass.java deleted file mode 100644 index 4659185706..0000000000 --- a/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/PathClass.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.nr.agent.instrumentation; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -@Controller -@RequestMapping("/pathClass") -public class PathClass { - - @RequestMapping("/methodTestPath") - public String testPath() { - return "PathClass"; - } -} \ No newline at end of file diff --git a/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/SpringControllerTests.java b/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/SpringControllerTests.java deleted file mode 100644 index 2df15332b5..0000000000 --- a/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/SpringControllerTests.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.nr.agent.instrumentation; - -import static org.junit.Assert.assertEquals; - -import java.util.Map; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.newrelic.agent.introspec.InstrumentationTestConfig; -import com.newrelic.agent.introspec.InstrumentationTestRunner; -import com.newrelic.agent.introspec.Introspector; -import com.newrelic.agent.introspec.TracedMetricData; - -@RunWith(InstrumentationTestRunner.class) -@InstrumentationTestConfig(includePrefixes = { "com.nr.agent.instrumentation" }) -public class SpringControllerTests { - - @Test - public void testErrorPath() { - App.error(); - - Introspector introspector = InstrumentationTestRunner.getIntrospector(); - String expectedTransactionName = "OtherTransaction/SpringController/errorPath (GET)"; - Map metrics = introspector.getMetricsForTransaction(expectedTransactionName); - assertEquals(1, metrics.get("Java/com.nr.agent.instrumentation.ErrorPath/testError").getCallCount()); - } - - @Test - public void testPathClass() { - assertEquals("PathClass", App.pathClass()); - - Introspector introspector = InstrumentationTestRunner.getIntrospector(); - String expectedTransactionName = "OtherTransaction/SpringController/pathClass/methodTestPath (GET)"; - Map metrics = introspector.getMetricsForTransaction(expectedTransactionName); - assertEquals(1, metrics.get("Java/com.nr.agent.instrumentation.PathClass/testPath").getCallCount()); - } - - @Test - public void testInnerPath() { - assertEquals("innerPath", App.innerPath()); - - Introspector introspector = InstrumentationTestRunner.getIntrospector(); - String expectedTransactionName = "OtherTransaction/SpringController/defaultPath/innerPath (GET)"; - Map metrics = introspector.getMetricsForTransaction(expectedTransactionName); - assertEquals(1, metrics.get("Java/com.nr.agent.instrumentation.TestInnerAndDefaultPath/testInnerPath").getCallCount()); - } - - @Test - public void testMethodPath() { - assertEquals("methodPath", App.methodPath()); - - Introspector introspector = InstrumentationTestRunner.getIntrospector(); - String expectedTransactionName = "OtherTransaction/SpringController/pathTest (GET)"; - Map metrics = introspector.getMetricsForTransaction(expectedTransactionName); - assertEquals(1, metrics.get("Java/com.nr.agent.instrumentation.TestPathAnnotationForMethod/testPathAnnotation").getCallCount()); - } - - @Test - public void testKotlinDefaultParameter() { - assertEquals("kotlinDefaultParameter", App.kotlinDefaultParameter()); - - Introspector introspector = InstrumentationTestRunner.getIntrospector(); - String expectedTransactionName = "OtherTransaction/SpringController/kotlin/read (GET)"; - Map metrics = introspector.getMetricsForTransaction(expectedTransactionName); - assertEquals(1, metrics.get("Java/com.nr.agent.instrumentation.KotlinSpringClass/read").getCallCount()); - } -} diff --git a/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/TestInnerAndDefaultPath.java b/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/TestInnerAndDefaultPath.java deleted file mode 100644 index be1d45ea29..0000000000 --- a/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/TestInnerAndDefaultPath.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.nr.agent.instrumentation; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - - -@Controller -@RequestMapping("/defaultPath") -public class TestInnerAndDefaultPath { - - @RequestMapping(value = "/innerPath") - public String testInnerPath() { - return "innerPath"; - } -} \ No newline at end of file diff --git a/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/TestPathAnnotationForMethod.java b/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/TestPathAnnotationForMethod.java deleted file mode 100644 index 9e84b786a7..0000000000 --- a/instrumentation/spring-3.0.0/src/test/java/com/nr/agent/instrumentation/TestPathAnnotationForMethod.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.nr.agent.instrumentation; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -@Controller -public class TestPathAnnotationForMethod { - - @RequestMapping(value = "/pathTest") - public String testPathAnnotation() { - return "methodPath"; - } -} diff --git a/instrumentation/spring-3.0.0/src/test/kotlin/com/nr/agent/instrumentation/KotlinSpringClass.kt b/instrumentation/spring-3.0.0/src/test/kotlin/com/nr/agent/instrumentation/KotlinSpringClass.kt deleted file mode 100644 index 71fb75c1fb..0000000000 --- a/instrumentation/spring-3.0.0/src/test/kotlin/com/nr/agent/instrumentation/KotlinSpringClass.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.nr.agent.instrumentation - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -@Controller -@RequestMapping(value = ["/kotlin"]) -class KotlinSpringClass constructor() { - - @RequestMapping(value = ["/read"]) - fun read(data: List, defaultParam: Int = 0): String { - for (string in data) { - System.out.println(string) - } - return "kotlinDefaultParameter" - } - -} diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/ActionInvocation.java b/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/ActionInvocation.java deleted file mode 100644 index 45191b3518..0000000000 --- a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/ActionInvocation.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.newrelic.agent.instrumentation.pointcuts.frameworks.struts; - -import com.newrelic.agent.instrumentation.pointcuts.InterfaceMixin; - -@InterfaceMixin(originalClassName = "com/opensymphony/xwork2/ActionInvocation") -public interface ActionInvocation { - Object getAction(); -} diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/ActionProxy.java b/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/ActionProxy.java deleted file mode 100644 index b2eb4d2953..0000000000 --- a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/ActionProxy.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.newrelic.agent.instrumentation.pointcuts.frameworks.struts; - -import com.newrelic.agent.instrumentation.pointcuts.InterfaceMixin; - -@InterfaceMixin(originalClassName = "com/opensymphony/xwork2/ActionProxy") -public interface ActionProxy { - String getActionName(); -} diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/StrutsActionConfigMatcherPointCut.java b/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/StrutsActionConfigMatcherPointCut.java deleted file mode 100644 index 85d95be430..0000000000 --- a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/StrutsActionConfigMatcherPointCut.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.newrelic.agent.instrumentation.pointcuts.frameworks.struts; - -import java.text.MessageFormat; -import java.util.logging.Level; - -import com.newrelic.agent.Agent; -import com.newrelic.agent.Transaction; -import com.newrelic.agent.bridge.TransactionNamePriority; -import com.newrelic.agent.instrumentation.PointCutClassTransformer; -import com.newrelic.agent.instrumentation.TracerFactoryPointCut; -import com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher; -import com.newrelic.agent.instrumentation.pointcuts.PointCut; -import com.newrelic.agent.tracers.ClassMethodSignature; -import com.newrelic.agent.tracers.MethodExitTracer; -import com.newrelic.agent.tracers.Tracer; -import com.newrelic.agent.transaction.TransactionNamingPolicy; -import com.newrelic.agent.util.Invoker; - -@PointCut -public class StrutsActionConfigMatcherPointCut extends TracerFactoryPointCut { - private static final String STRUTS = "Struts"; - private static final String ACTION_CONFIG_MATCHER_CLASS = "org/apache/struts/config/ActionConfigMatcher"; - private static final String GET_PATH = "getPath"; - - public StrutsActionConfigMatcherPointCut(PointCutClassTransformer classTransformer) { - super( - StrutsActionConfigMatcherPointCut.class, - new ExactClassMatcher(ACTION_CONFIG_MATCHER_CLASS), - createExactMethodMatcher("convertActionConfig", - "(Ljava/lang/String;Lorg/apache/struts/config/ActionConfig;Ljava/util/Map;)Lorg/apache/struts/config/ActionConfig;")); - } - - @Override - public Tracer doGetTracer(Transaction transaction, ClassMethodSignature sig, Object matcher, Object[] args) { - return new StrutsActionConfigMatcherTracer(transaction, sig, matcher, args); - } - - private static class StrutsActionConfigMatcherTracer extends MethodExitTracer { - public StrutsActionConfigMatcherTracer(Transaction transaction, ClassMethodSignature sig, Object matcher, - Object[] args) { - super(sig, transaction); - try { - Object actionConfig = args[1]; - String wildcardPath = (String) Invoker.invoke(actionConfig, actionConfig.getClass(), GET_PATH); - Agent.LOG.finer("Normalizing path using Struts wildcard"); - setTransactionName(transaction, wildcardPath); - } catch (Exception e) { - String msg = MessageFormat.format("Exception in {0} handling {1}: {2}", - StrutsActionConfigMatcherPointCut.class.getSimpleName(), sig, e); - if (Agent.LOG.isLoggable(Level.FINEST)) { - Agent.LOG.log(Level.FINEST, msg, e); - } else { - Agent.LOG.finer(msg); - } - } - } - - private void setTransactionName(Transaction transaction, String wildcardPath) { - if (!transaction.isTransactionNamingEnabled()) { - return; - } - TransactionNamingPolicy policy = TransactionNamingPolicy.getHigherPriorityTransactionNamingPolicy(); - if (Agent.LOG.isLoggable(Level.FINER)) { - if (policy.canSetTransactionName(transaction, TransactionNamePriority.FRAMEWORK)) { - String msg = MessageFormat.format("Setting transaction name to \"{0}\" using Struts wildcard", - wildcardPath); - Agent.LOG.finer(msg); - } - } - policy.setTransactionName(transaction, wildcardPath, STRUTS, TransactionNamePriority.FRAMEWORK); - } - - @Override - protected void doFinish(int opcode, Object returnValue) { - // no op - } - - } -} diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/StrutsActionPointCut.java b/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/StrutsActionPointCut.java deleted file mode 100644 index 6bcd190188..0000000000 --- a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/StrutsActionPointCut.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.newrelic.agent.instrumentation.pointcuts.frameworks.struts; - -import java.text.MessageFormat; -import java.util.logging.Level; - -import com.newrelic.agent.Agent; -import com.newrelic.agent.MetricNames; -import com.newrelic.agent.Transaction; -import com.newrelic.agent.bridge.TransactionNamePriority; -import com.newrelic.agent.instrumentation.PointCutClassTransformer; -import com.newrelic.agent.instrumentation.TracerFactoryPointCut; -import com.newrelic.agent.instrumentation.classmatchers.ChildClassMatcher; -import com.newrelic.agent.instrumentation.methodmatchers.MethodMatcher; -import com.newrelic.agent.instrumentation.pointcuts.PointCut; -import com.newrelic.agent.tracers.ClassMethodSignature; -import com.newrelic.agent.tracers.DefaultTracer; -import com.newrelic.agent.tracers.Tracer; -import com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat; -import com.newrelic.agent.transaction.TransactionNamingPolicy; - -/** - * Instruments the execute method of Struts actions. - */ -@PointCut -public class StrutsActionPointCut extends TracerFactoryPointCut { - public static final String STRUTS_ACTION_CLASS = "org/apache/struts/action/Action"; - private static final MethodMatcher METHOD_MATCHER = createExactMethodMatcher( - "execute", - "(Lorg/apache/struts/action/ActionMapping;Lorg/apache/struts/action/ActionForm;Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;)Lorg/apache/struts/action/ActionForward;", - "(Lorg/apache/struts/action/ActionMapping;Lorg/apache/struts/action/ActionForm;Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)Lorg/apache/struts/action/ActionForward;"); - - public StrutsActionPointCut(PointCutClassTransformer classTransformer) { - super(StrutsActionPointCut.class, new ChildClassMatcher(STRUTS_ACTION_CLASS), METHOD_MATCHER); - } - - @Override - public Tracer doGetTracer(Transaction transaction, ClassMethodSignature sig, Object action, Object[] args) { - return new StrutsActionTracer(transaction, sig, action, args); - } - - private static class StrutsActionTracer extends DefaultTracer { - private final String actionClassName; - - public StrutsActionTracer(Transaction transaction, ClassMethodSignature sig, Object action, Object[] args) { - super(transaction, sig, action); - actionClassName = action.getClass().getName(); - setTransactionName(transaction, actionClassName); - setMetricNameFormat(new SimpleMetricNameFormat("StrutsAction/" + actionClassName)); - } - - private void setTransactionName(Transaction tx, String action) { - if (!tx.isTransactionNamingEnabled()) { - return; - } - TransactionNamingPolicy policy = TransactionNamingPolicy.getHigherPriorityTransactionNamingPolicy(); - if (Agent.LOG.isLoggable(Level.FINER)) { - if (policy.canSetTransactionName(tx, TransactionNamePriority.FRAMEWORK)) { - String msg = MessageFormat.format("Setting transaction name to \"{0}\" using Struts action", action); - Agent.LOG.finer(msg); - } - } - policy.setTransactionName(tx, action, MetricNames.STRUTS_ACTION, TransactionNamePriority.FRAMEWORK); - } - - } - -} diff --git a/settings.gradle b/settings.gradle index 05bc676a20..2a570e31f4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -74,7 +74,6 @@ include 'instrumentation:aws-java-sdk-sqs-2.1.0' include 'instrumentation:aws-java-sdk-dynamodb-1.11.106' include 'instrumentation:aws-java-sdk-dynamodb-2.15.34' include 'instrumentation:aws-java-sdk-sns-2.0' -include 'instrumentation:aws-wrap-0.7.0' include 'instrumentation:akka-2.2' include 'instrumentation:akka-http-2.11_2.4.5' include 'instrumentation:akka-http-2.13_10.1.8' @@ -141,7 +140,6 @@ include 'instrumentation:httpurlconnection' include 'instrumentation:hystrix-1.3.15' include 'instrumentation:hystrix-1.4' include 'instrumentation:jakarta.xml' -include 'instrumentation:java.completable-future-jdk8' include 'instrumentation:java.completable-future-jdk8u40' include 'instrumentation:java.logging-jdk8' include 'instrumentation:java-io' @@ -250,7 +248,6 @@ include 'instrumentation:mule-ei1' include 'instrumentation:mule-ei2' include 'instrumentation:mule-3.6' include 'instrumentation:mule-3.7' -include 'instrumentation:netty-3.4' include 'instrumentation:netty-3.8' include 'instrumentation:netty-4.0.0' include 'instrumentation:netty-4.0.8' @@ -265,7 +262,6 @@ include 'instrumentation:open-liberty-jakarta-21.0.0.12' include 'instrumentation:openjpa-1.0.0' include 'instrumentation:openejb-3.0' include 'instrumentation:oracle-r2dbc' -include 'instrumentation:play-2.3' include 'instrumentation:play-2.4' include 'instrumentation:play-2.5' include 'instrumentation:play-2.6' @@ -326,7 +322,6 @@ include 'instrumentation:spray-can-1.3.1' include 'instrumentation:spray-client-1.3.1' include 'instrumentation:spray-can-http-client-1.3.1' include 'instrumentation:spray-http-1.3.1' -include 'instrumentation:spring-3.0.0' include 'instrumentation:spring-4.0.0' include 'instrumentation:spring-4.2.0' include 'instrumentation:spring-4.3.0'