-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #302 from newrelic/feature/api-endpoint/vertx-NR-2…
…87771 [NR-287771] API Endpoint and Route detection Support for Vert.x Framework
- Loading branch information
Showing
16 changed files
with
656 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ecurity/vertx-core-3.3.0/src/main/java/io/vertx/core/http/HttpServer_Instrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.vertx.core.http; | ||
|
||
import com.newrelic.api.agent.security.NewRelicSecurity; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.GenericHelper; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.VertxApiEndpointUtils; | ||
import com.newrelic.api.agent.security.utils.logging.LogLevel; | ||
import com.newrelic.api.agent.weaver.MatchType; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
import io.vertx.core.Handler; | ||
|
||
@Weave(originalName = "io.vertx.core.http.HttpServer", type = MatchType.Interface) | ||
public class HttpServer_Instrumentation { | ||
|
||
public HttpServer_Instrumentation requestHandler(Handler<HttpServerRequest> handler){ | ||
HttpServer_Instrumentation server = Weaver.callOriginal(); | ||
try { | ||
VertxApiEndpointUtils.getInstance().generateAPIEndpoints(handler.hashCode()); | ||
} catch (Exception e){ | ||
NewRelicSecurity.getAgent().log(LogLevel.WARNING, String.format(GenericHelper.ERROR_WHILE_GETTING_APP_ENDPOINTS, "VERTX-CORE-3.3.0", e.getMessage()), e, VertxApiEndpointUtils.class.getName()); | ||
} | ||
return server; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...ecurity/vertx-core-3.4.0/src/main/java/io/vertx/core/http/HttpServer_Instrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.vertx.core.http; | ||
|
||
import com.newrelic.api.agent.security.NewRelicSecurity; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.GenericHelper; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.VertxApiEndpointUtils; | ||
import com.newrelic.api.agent.security.utils.logging.LogLevel; | ||
import com.newrelic.api.agent.weaver.MatchType; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
import io.vertx.core.Handler; | ||
|
||
|
||
@Weave(originalName = "io.vertx.core.http.HttpServer", type = MatchType.Interface) | ||
public class HttpServer_Instrumentation { | ||
|
||
public HttpServer_Instrumentation requestHandler(Handler<HttpServerRequest> handler){ | ||
HttpServer_Instrumentation server = Weaver.callOriginal(); | ||
try { | ||
VertxApiEndpointUtils.getInstance().generateAPIEndpoints(handler.hashCode()); | ||
} catch (Exception e){ | ||
NewRelicSecurity.getAgent().log(LogLevel.WARNING, String.format(GenericHelper.ERROR_WHILE_GETTING_APP_ENDPOINTS, "VERTX-CORE-3.4.0", e.getMessage()), e, VertxApiEndpointUtils.class.getName()); | ||
} | ||
return server; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ecurity/vertx-core-3.7.1/src/main/java/io/vertx/core/http/HttpServer_Instrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.vertx.core.http; | ||
|
||
import com.newrelic.api.agent.security.NewRelicSecurity; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.GenericHelper; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.VertxApiEndpointUtils; | ||
import com.newrelic.api.agent.security.utils.logging.LogLevel; | ||
import com.newrelic.api.agent.weaver.MatchType; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
import io.vertx.core.Handler; | ||
|
||
@Weave(originalName = "io.vertx.core.http.HttpServer", type = MatchType.Interface) | ||
public class HttpServer_Instrumentation { | ||
|
||
public HttpServer_Instrumentation requestHandler(Handler<HttpServerRequest> handler){ | ||
HttpServer_Instrumentation server = Weaver.callOriginal(); | ||
try { | ||
VertxApiEndpointUtils.getInstance().generateAPIEndpoints(handler.hashCode()); | ||
} catch (Exception e){ | ||
NewRelicSecurity.getAgent().log(LogLevel.WARNING, String.format(GenericHelper.ERROR_WHILE_GETTING_APP_ENDPOINTS, "VERTX-CORE-3.7.1", e.getMessage()), e, VertxApiEndpointUtils.class.getName()); | ||
} | ||
return server; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...ecurity/vertx-core-4.0.0/src/main/java/io/vertx/core/http/HttpServer_Instrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.vertx.core.http; | ||
|
||
import com.newrelic.api.agent.security.NewRelicSecurity; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.GenericHelper; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.VertxApiEndpointUtils; | ||
import com.newrelic.api.agent.security.utils.logging.LogLevel; | ||
import com.newrelic.api.agent.weaver.MatchType; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
import io.vertx.core.Handler; | ||
|
||
|
||
|
||
@Weave(originalName = "io.vertx.core.http.HttpServer", type = MatchType.Interface) | ||
public class HttpServer_Instrumentation { | ||
|
||
public HttpServer_Instrumentation requestHandler(Handler<HttpServerRequest> handler){ | ||
HttpServer_Instrumentation server = Weaver.callOriginal(); | ||
try { | ||
VertxApiEndpointUtils.getInstance().generateAPIEndpoints(handler.hashCode()); | ||
} catch (Exception e){ | ||
NewRelicSecurity.getAgent().log(LogLevel.WARNING, String.format(GenericHelper.ERROR_WHILE_GETTING_APP_ENDPOINTS, "VERTX-CORE-4.0.0", e.getMessage()), e, VertxApiEndpointUtils.class.getName()); | ||
} | ||
return server; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ation-security/vertx-web-3.2.0/src/main/java/io/vertx/ext/web/Router_Instrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.vertx.ext.web; | ||
|
||
import com.newrelic.api.agent.security.instrumentation.helpers.ThreadLocalLockHelper; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.VertxApiEndpointUtils; | ||
import com.newrelic.api.agent.weaver.MatchType; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
|
||
@Weave(originalName = "io.vertx.ext.web.Router", type = MatchType.Interface) | ||
public class Router_Instrumentation { | ||
|
||
public Router_Instrumentation mountSubRouter(String mountPoint, Router subRouter) { | ||
Router_Instrumentation result; | ||
boolean isLockAcquired = ThreadLocalLockHelper.acquireLock(); | ||
try { | ||
result = Weaver.callOriginal(); | ||
} finally { | ||
if (isLockAcquired) { | ||
ThreadLocalLockHelper.releaseLock(); | ||
} | ||
} | ||
VertxApiEndpointUtils.getInstance().resolveSubRoutes(this.hashCode(), subRouter.hashCode(), mountPoint); | ||
return result; | ||
} | ||
} |
67 changes: 66 additions & 1 deletion
67
...curity/vertx-web-3.2.0/src/main/java/io/vertx/ext/web/impl/RouteImpl_Instrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,80 @@ | ||
package io.vertx.ext.web.impl; | ||
|
||
import com.newrelic.api.agent.security.NewRelicSecurity; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.GenericHelper; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.ServletHelper; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.VertxApiEndpointUtils; | ||
import com.newrelic.api.agent.security.utils.logging.LogLevel; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.http.HttpMethod; | ||
import io.vertx.ext.web.Route; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
@Weave(originalName = "io.vertx.ext.web.impl.RouteImpl") | ||
public class RouteImpl_Instrumentation { | ||
public abstract class RouteImpl_Instrumentation { | ||
|
||
private final RouterImpl router = Weaver.callOriginal(); | ||
|
||
private String path = Weaver.callOriginal(); | ||
|
||
private Pattern pattern = Weaver.callOriginal(); | ||
|
||
RouteImpl_Instrumentation(RouterImpl router, int order){ | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), null, null, null); | ||
} | ||
|
||
RouteImpl_Instrumentation(RouterImpl router, int order, HttpMethod method, String path) { | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), path, null, method.name()); | ||
} | ||
|
||
RouteImpl_Instrumentation(RouterImpl router, int order, String path) { | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), path, null, null); | ||
} | ||
|
||
RouteImpl_Instrumentation(RouterImpl router, int order, HttpMethod method, String regex, boolean bregex) { | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), null, regex, method.name()); | ||
} | ||
|
||
RouteImpl_Instrumentation(RouterImpl router, int order, String regex, boolean bregex) { | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), null, regex, null); | ||
} | ||
|
||
synchronized void handleContext(RoutingContext context) { | ||
try { | ||
VertxApiEndpointUtils.getInstance().generateAPIEndpointsIfNotPresent(this.hashCode()); | ||
VertxApiEndpointUtils.getInstance().routeDetection(path, pattern); | ||
} catch (Exception e) { | ||
NewRelicSecurity.getAgent().log(LogLevel.WARNING, String.format(GenericHelper.ERROR_WHILE_GETTING_ROUTE_FOR_INCOMING_REQUEST, "VERTX-WEB-3.2.0", e.getMessage()), e, this.getClass().getName()); | ||
} | ||
ServletHelper.registerUserLevelCode("vertx-web"); | ||
Weaver.callOriginal(); | ||
} | ||
|
||
public synchronized Route method(HttpMethod method) { | ||
Route route = Weaver.callOriginal(); | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), null, null, method.name()); | ||
return route; | ||
} | ||
|
||
public synchronized Route path(String path) { | ||
Route route = Weaver.callOriginal(); | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), path, null, null); | ||
return route; | ||
} | ||
|
||
public synchronized Route pathRegex(String regex) { | ||
Route route = Weaver.callOriginal(); | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), null, regex, null); | ||
return route; | ||
} | ||
|
||
public synchronized Route handler(Handler<RoutingContext> contextHandler){ | ||
Route route = Weaver.callOriginal(); | ||
VertxApiEndpointUtils.getInstance().addHandlerClass(router.hashCode(), this.hashCode(), contextHandler.getClass().getName()); | ||
return route; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ation-security/vertx-web-3.5.1/src/main/java/io/vertx/ext/web/Router_Instrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.vertx.ext.web; | ||
|
||
import com.newrelic.api.agent.security.instrumentation.helpers.ThreadLocalLockHelper; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.VertxApiEndpointUtils; | ||
import com.newrelic.api.agent.weaver.MatchType; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
|
||
@Weave(originalName = "io.vertx.ext.web.Router", type = MatchType.Interface) | ||
public class Router_Instrumentation { | ||
|
||
public Router_Instrumentation mountSubRouter(String mountPoint, Router subRouter) { | ||
Router_Instrumentation result; | ||
boolean isLockAcquired = ThreadLocalLockHelper.acquireLock(); | ||
try { | ||
result = Weaver.callOriginal(); | ||
} finally { | ||
if (isLockAcquired) { | ||
ThreadLocalLockHelper.releaseLock(); | ||
} | ||
} | ||
VertxApiEndpointUtils.getInstance().resolveSubRoutes(this.hashCode(), subRouter.hashCode(), mountPoint); | ||
return result; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...curity/vertx-web-3.5.1/src/main/java/io/vertx/ext/web/impl/RouteImpl_Instrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,81 @@ | ||
package io.vertx.ext.web.impl; | ||
|
||
import com.newrelic.api.agent.security.NewRelicSecurity; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.GenericHelper; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.ServletHelper; | ||
import com.newrelic.api.agent.security.instrumentation.helpers.VertxApiEndpointUtils; | ||
import com.newrelic.api.agent.security.schema.Framework; | ||
import com.newrelic.api.agent.security.utils.logging.LogLevel; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.http.HttpMethod; | ||
import io.vertx.ext.web.Route; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
@Weave(originalName = "io.vertx.ext.web.impl.RouteImpl") | ||
public class RouteImpl_Instrumentation { | ||
|
||
private final RouterImpl router = Weaver.callOriginal(); | ||
|
||
private String path = Weaver.callOriginal(); | ||
|
||
private Pattern pattern = Weaver.callOriginal(); | ||
|
||
RouteImpl_Instrumentation(RouterImpl router, int order){ | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), null, null, null); | ||
} | ||
|
||
RouteImpl_Instrumentation(RouterImpl router, int order, HttpMethod method, String path) { | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), path, null, method.name()); | ||
} | ||
|
||
RouteImpl_Instrumentation(RouterImpl router, int order, String path) { | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), path, null, null); | ||
} | ||
|
||
RouteImpl_Instrumentation(RouterImpl router, int order, HttpMethod method, String regex, boolean bregex) { | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), null, regex, method.name()); | ||
} | ||
|
||
RouteImpl_Instrumentation(RouterImpl router, int order, String regex, boolean bregex) { | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), null, regex, null); | ||
} | ||
|
||
void handleContext(RoutingContextImplBase context) { | ||
try { | ||
VertxApiEndpointUtils.getInstance().generateAPIEndpointsIfNotPresent(this.hashCode()); | ||
VertxApiEndpointUtils.getInstance().routeDetection(path, pattern); | ||
} catch (Exception e) { | ||
NewRelicSecurity.getAgent().log(LogLevel.WARNING, String.format(GenericHelper.ERROR_WHILE_GETTING_ROUTE_FOR_INCOMING_REQUEST, "VERTX-WEB-3.5.1", e.getMessage()), e, this.getClass().getName()); | ||
} | ||
ServletHelper.registerUserLevelCode("vertx-web"); | ||
Weaver.callOriginal(); | ||
} | ||
|
||
public synchronized Route method(HttpMethod method) { | ||
Route route = Weaver.callOriginal(); | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), null, null, method.name()); | ||
return route; | ||
} | ||
|
||
public synchronized Route path(String path) { | ||
Route route = Weaver.callOriginal(); | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), path, null, null); | ||
return route; | ||
} | ||
|
||
public synchronized Route pathRegex(String regex) { | ||
Route route = Weaver.callOriginal(); | ||
VertxApiEndpointUtils.getInstance().addRouteImpl(router.hashCode(), this.hashCode(), null, regex, null); | ||
return route; | ||
} | ||
|
||
public synchronized Route handler(Handler<RoutingContext> contextHandler){ | ||
Route route = Weaver.callOriginal(); | ||
VertxApiEndpointUtils.getInstance().addHandlerClass(router.hashCode(), this.hashCode(), contextHandler.getClass().getName()); | ||
return route; | ||
} | ||
} |
Oops, something went wrong.