Skip to content

Commit

Permalink
Merge pull request #6 from newrelic-experimental/quarkus-enhancement
Browse files Browse the repository at this point in the history
Quarkus enhancement
  • Loading branch information
gsidhwani-nr authored Aug 26, 2024
2 parents bca2b23 + e108ca0 commit dc925d7
Show file tree
Hide file tree
Showing 50 changed files with 3,084 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,53 @@

import java.util.Map;

import com.newrelic.api.agent.NewRelic;
import com.newrelic.api.agent.TransactionNamePriority;

import io.vertx.ext.web.Route;
import io.vertx.ext.web.RoutingContext;

public class Utils {

public static final String NEWRELIC_TOKEN = "NewRelic-Token";

public static void addAttribute(Map<String, Object> attributes, String key, Object value) {
if(attributes != null && key != null && !key.isEmpty() && value != null) {
attributes.put(key, value);
}
public static final String NEWRELIC_TOKEN = "NewRelic-Token";

public static void addAttribute(Map<String, Object> attributes, String key, Object value) {
if (attributes != null && key != null && !key.isEmpty() && value != null) {
attributes.put(key, value);
}
}

public static void addRoute(Map<String, Object> attributes, Route route) {
if (route != null) {
addAttribute(attributes, "Route-Name", route.getName());
addAttribute(attributes, "Route-Path", route.getPath());
}
}

public static void setTransactionName(Map<String, Object> attributes, Route route) {
if (route != null) {
addAttribute(attributes, "Route-Name", route.getName());
addAttribute(attributes, "Route-Path", route.getPath());
}
}

public static void setTransactionName(RoutingContext request) {
String name = " ";
String route = request.currentRoute().getName();
if (route != null & route.length() > 0) {
name += route;
}

public static void addRoute(Map<String, Object> attributes, Route route) {
if(route != null) {
addAttribute(attributes, "Route-Name", route.getName());
addAttribute(attributes, "Route-Path", route.getPath());
}
String path = request.currentRoute().getPath();
if (path != null & path.length() > 0) {
name += ":" + path;
}
String method = request.request().method().name();
if (method != null & method.length() > 0) {
name += " (" + method + ")";
}
System.out.println(name);
NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, false, "Quarkus",
"resteasy", name);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
@Weave
public abstract class RequestDispatcher {

@Trace
public void service(Context context,
HttpServerRequest req,
HttpServerResponse resp,
HttpRequest vertxReq, HttpResponse vertxResp, boolean handleNotFound) {
Weaver.callOriginal();
}
@Trace
public void service(Context context, HttpServerRequest req, HttpServerResponse resp, HttpRequest vertxReq,
HttpResponse vertxResp, boolean handleNotFound) {
Weaver.callOriginal();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@
@Weave
public class VertxRequestHandler {

@Trace
public void handle(RoutingContext request) {
HashMap<String, Object> attributes = new HashMap<String, Object>();
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", request.normalizedPath());
Utils.addRoute(attributes, request.currentRoute());
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);

Weaver.callOriginal();
}

@Trace
private void dispatch(RoutingContext routingContext, InputStream is, VertxOutput output) {
HashMap<String, Object> attributes = new HashMap<String, Object>();
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", routingContext.normalizedPath());
Utils.addRoute(attributes, routingContext.currentRoute());
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
Weaver.callOriginal();
}
@Trace
public void handle(RoutingContext request) {
HashMap<String, Object> attributes = new HashMap<String, Object>();
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", request.normalizedPath());
Utils.addRoute(attributes, request.currentRoute());
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
Utils.setTransactionName(request);
Weaver.callOriginal();
}

@Trace
private void dispatch(RoutingContext routingContext, InputStream is, VertxOutput output) {
HashMap<String, Object> attributes = new HashMap<String, Object>();
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", routingContext.normalizedPath());
Utils.addRoute(attributes, routingContext.currentRoute());
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);

Weaver.callOriginal();
}

}
2 changes: 1 addition & 1 deletion quarkus-resteasy-2.11/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {

jar {
manifest {
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.quarkus-resteasy-2.0'
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.quarkus-resteasy-2.11.0'
attributes 'Implementation-Vendor': 'New Relic Labs'
attributes 'Implementation-Vendor-Id': 'com.newrelic.labs'
attributes 'Implementation-Version': 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,46 @@

import java.util.Map;

import com.newrelic.api.agent.NewRelic;
import com.newrelic.api.agent.TransactionNamePriority;

import io.vertx.ext.web.Route;
import io.vertx.ext.web.RoutingContext;

public class Utils {

public static final String NEWRELIC_TOKEN = "NewRelic-Token";

public static void addAttribute(Map<String, Object> attributes, String key, Object value) {
if(attributes != null && key != null && !key.isEmpty() && value != null) {
attributes.put(key, value);
}
public static final String NEWRELIC_TOKEN = "NewRelic-Token";

public static void addAttribute(Map<String, Object> attributes, String key, Object value) {
if (attributes != null && key != null && !key.isEmpty() && value != null) {
attributes.put(key, value);
}
}

public static void addRoute(Map<String, Object> attributes, Route route) {
if (route != null) {
addAttribute(attributes, "Route-Name", route.getName());
addAttribute(attributes, "Route-Path", route.getPath());
}

public static void addRoute(Map<String, Object> attributes, Route route) {
if(route != null) {
addAttribute(attributes, "Route-Name", route.getName());
addAttribute(attributes, "Route-Path", route.getPath());
}
}

public static void setTransactionName(RoutingContext request) {
String name = " ";
String route = request.currentRoute().getName();
if (route != null & route.length() > 0) {
name += route;
}
String path = request.currentRoute().getPath();
if (path != null & path.length() > 0) {
name += ":" + path;
}
String method = request.request().method().name();
if (method != null & method.length() > 0) {
name += " (" + method + ")";
}
System.out.println(name);
NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, false, "Quarkus",
"resteasy", name);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
@Weave
public abstract class RequestDispatcher {

@Trace
public void service(Context context,
HttpServerRequest req,
HttpServerResponse resp,
HttpRequest vertxReq, HttpResponse vertxResp, boolean handleNotFound) {
Weaver.callOriginal();
}
@Trace
public void service(Context context, HttpServerRequest req, HttpServerResponse resp, HttpRequest vertxReq,
HttpResponse vertxResp, boolean handleNotFound) {

Weaver.callOriginal();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@
@Weave
public class VertxRequestHandler {

@Trace
public void handle(RoutingContext request) {
HashMap<String, Object> attributes = new HashMap<String, Object>();
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", request.normalizedPath());
Utils.addRoute(attributes, request.currentRoute());
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);

Weaver.callOriginal();
}

@Trace
private void dispatch(RoutingContext routingContext, InputStream is, VertxOutput output) {
HashMap<String, Object> attributes = new HashMap<String, Object>();
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", routingContext.normalizedPath());
Utils.addRoute(attributes, routingContext.currentRoute());
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
Weaver.callOriginal();
}
@Trace
public void handle(RoutingContext request) {
HashMap<String, Object> attributes = new HashMap<String, Object>();
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", request.normalizedPath());
Utils.addRoute(attributes, request.currentRoute());
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
Utils.setTransactionName(request);
Weaver.callOriginal();
}

@Trace
private void dispatch(RoutingContext routingContext, InputStream is, VertxOutput output) {
HashMap<String, Object> attributes = new HashMap<String, Object>();
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", routingContext.normalizedPath());
Utils.addRoute(attributes, routingContext.currentRoute());
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);

Weaver.callOriginal();
}

}
2 changes: 1 addition & 1 deletion quarkus-resteasy-2.14.1/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {

jar {
manifest {
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.quarkus-resteasy-2.0'
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.quarkus-resteasy-2.14.1'
attributes 'Implementation-Vendor': 'New Relic Labs'
attributes 'Implementation-Vendor-Id': 'com.newrelic.labs'
attributes 'Implementation-Version': 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,46 @@

import java.util.Map;

import com.newrelic.api.agent.NewRelic;
import com.newrelic.api.agent.TransactionNamePriority;

import io.vertx.ext.web.Route;
import io.vertx.ext.web.RoutingContext;

public class Utils {

public static final String NEWRELIC_TOKEN = "NewRelic-Token";

public static void addAttribute(Map<String, Object> attributes, String key, Object value) {
if(attributes != null && key != null && !key.isEmpty() && value != null) {
attributes.put(key, value);
}
public static final String NEWRELIC_TOKEN = "NewRelic-Token";

public static void addAttribute(Map<String, Object> attributes, String key, Object value) {
if (attributes != null && key != null && !key.isEmpty() && value != null) {
attributes.put(key, value);
}
}

public static void addRoute(Map<String, Object> attributes, Route route) {
if (route != null) {
addAttribute(attributes, "Route-Name", route.getName());
addAttribute(attributes, "Route-Path", route.getPath());
}

public static void addRoute(Map<String, Object> attributes, Route route) {
if(route != null) {
addAttribute(attributes, "Route-Name", route.getName());
addAttribute(attributes, "Route-Path", route.getPath());
}
}

public static void setTransactionName(RoutingContext request) {
String name = " ";
String route = request.currentRoute().getName();
if (route != null & route.length() > 0) {
name += route;
}
String path = request.currentRoute().getPath();
if (path != null & path.length() > 0) {
name += ":" + path;
}
String method = request.request().method().name();
if (method != null & method.length() > 0) {
name += " (" + method + ")";
}
System.out.println(name);
NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, false, "Quarkus",
"resteasy", name);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
@Weave
public abstract class RequestDispatcher {

@Trace
public void service(Context context,
HttpServerRequest req,
HttpServerResponse resp,
HttpRequest vertxReq, HttpResponse vertxResp, boolean handleNotFound, Throwable t) {
if(t != null) {
NewRelic.noticeError(t);
}
Weaver.callOriginal();
@Trace
public void service(Context context, HttpServerRequest req, HttpServerResponse resp, HttpRequest vertxReq,
HttpResponse vertxResp, boolean handleNotFound, Throwable t) {
if (t != null) {
NewRelic.noticeError(t);
}

Weaver.callOriginal();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@
@Weave
public class VertxRequestHandler {

@Trace
public void handle(RoutingContext request) {
HashMap<String, Object> attributes = new HashMap<String, Object>();
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", request.normalizedPath());
Utils.addRoute(attributes, request.currentRoute());
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);

Weaver.callOriginal();
}

@Trace
private void dispatch(RoutingContext routingContext, InputStream is, VertxOutput output) {
HashMap<String, Object> attributes = new HashMap<String, Object>();
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", routingContext.normalizedPath());
Utils.addRoute(attributes, routingContext.currentRoute());
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
Weaver.callOriginal();
}
@Trace
public void handle(RoutingContext request) {
HashMap<String, Object> attributes = new HashMap<String, Object>();
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", request.normalizedPath());
Utils.addRoute(attributes, request.currentRoute());
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
Utils.setTransactionName(request);
Weaver.callOriginal();
}

@Trace
private void dispatch(RoutingContext routingContext, InputStream is, VertxOutput output) {
HashMap<String, Object> attributes = new HashMap<String, Object>();
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", routingContext.normalizedPath());
Utils.addRoute(attributes, routingContext.currentRoute());
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);

Weaver.callOriginal();
}

}
2 changes: 1 addition & 1 deletion quarkus-resteasy-reactive-2.0/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jar {
verifyInstrumentation {
passes 'io.quarkus:quarkus-resteasy-reactive:[2.0.0.Final,2.6.0.Final)'
excludeRegex '.*CR.*'
}
}
Loading

0 comments on commit dc925d7

Please sign in to comment.