From 06e9d2ed33916f3f51c59d732896a5c459fc8fd1 Mon Sep 17 00:00:00 2001 From: Jason Keller Date: Wed, 6 Dec 2023 10:19:45 -0800 Subject: [PATCH] Remove deprecated play-2.3 instrumentation --- instrumentation/play-2.3/build.gradle | 39 ---------------- .../src/main/scala/play/api/mvc/Action.scala | 25 ---------- .../main/scala/play/core/router/Router.scala | 46 ------------------- .../main/scala/play/core/server/Server.scala | 30 ------------ settings.gradle | 1 - 5 files changed, 141 deletions(-) delete mode 100644 instrumentation/play-2.3/build.gradle delete mode 100644 instrumentation/play-2.3/src/main/scala/play/api/mvc/Action.scala delete mode 100644 instrumentation/play-2.3/src/main/scala/play/core/router/Router.scala delete mode 100644 instrumentation/play-2.3/src/main/scala/play/core/server/Server.scala 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/settings.gradle b/settings.gradle index 05bc676a20..322ff238f4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -265,7 +265,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'