Skip to content

Commit dc925d7

Browse files
authored
Merge pull request #6 from newrelic-experimental/quarkus-enhancement
Quarkus enhancement
2 parents bca2b23 + e108ca0 commit dc925d7

File tree

50 files changed

+3084
-127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3084
-127
lines changed

quarkus-resteasy-2.0/src/main/java/com/newrelic/instrumentation/quarkus/resteasy/Utils.java

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,53 @@
22

33
import java.util.Map;
44

5+
import com.newrelic.api.agent.NewRelic;
6+
import com.newrelic.api.agent.TransactionNamePriority;
7+
58
import io.vertx.ext.web.Route;
9+
import io.vertx.ext.web.RoutingContext;
610

711
public class Utils {
812

9-
public static final String NEWRELIC_TOKEN = "NewRelic-Token";
10-
11-
public static void addAttribute(Map<String, Object> attributes, String key, Object value) {
12-
if(attributes != null && key != null && !key.isEmpty() && value != null) {
13-
attributes.put(key, value);
14-
}
13+
public static final String NEWRELIC_TOKEN = "NewRelic-Token";
14+
15+
public static void addAttribute(Map<String, Object> attributes, String key, Object value) {
16+
if (attributes != null && key != null && !key.isEmpty() && value != null) {
17+
attributes.put(key, value);
18+
}
19+
}
20+
21+
public static void addRoute(Map<String, Object> attributes, Route route) {
22+
if (route != null) {
23+
addAttribute(attributes, "Route-Name", route.getName());
24+
addAttribute(attributes, "Route-Path", route.getPath());
25+
}
26+
}
27+
28+
public static void setTransactionName(Map<String, Object> attributes, Route route) {
29+
if (route != null) {
30+
addAttribute(attributes, "Route-Name", route.getName());
31+
addAttribute(attributes, "Route-Path", route.getPath());
32+
}
33+
}
34+
35+
public static void setTransactionName(RoutingContext request) {
36+
String name = " ";
37+
String route = request.currentRoute().getName();
38+
if (route != null & route.length() > 0) {
39+
name += route;
1540
}
16-
17-
public static void addRoute(Map<String, Object> attributes, Route route) {
18-
if(route != null) {
19-
addAttribute(attributes, "Route-Name", route.getName());
20-
addAttribute(attributes, "Route-Path", route.getPath());
21-
}
41+
String path = request.currentRoute().getPath();
42+
if (path != null & path.length() > 0) {
43+
name += ":" + path;
2244
}
45+
String method = request.request().method().name();
46+
if (method != null & method.length() > 0) {
47+
name += " (" + method + ")";
48+
}
49+
System.out.println(name);
50+
NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, false, "Quarkus",
51+
"resteasy", name);
52+
53+
}
2354
}

quarkus-resteasy-2.0/src/main/java/io/quarkus/resteasy/runtime/standalone/RequestDispatcher.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
@Weave
1515
public abstract class RequestDispatcher {
1616

17-
@Trace
18-
public void service(Context context,
19-
HttpServerRequest req,
20-
HttpServerResponse resp,
21-
HttpRequest vertxReq, HttpResponse vertxResp, boolean handleNotFound) {
22-
Weaver.callOriginal();
23-
}
17+
@Trace
18+
public void service(Context context, HttpServerRequest req, HttpServerResponse resp, HttpRequest vertxReq,
19+
HttpResponse vertxResp, boolean handleNotFound) {
20+
Weaver.callOriginal();
21+
}
2422
}

quarkus-resteasy-2.0/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxRequestHandler.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,24 @@
1414
@Weave
1515
public class VertxRequestHandler {
1616

17-
@Trace
18-
public void handle(RoutingContext request) {
19-
HashMap<String, Object> attributes = new HashMap<String, Object>();
20-
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", request.normalizedPath());
21-
Utils.addRoute(attributes, request.currentRoute());
22-
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
23-
24-
Weaver.callOriginal();
25-
}
26-
27-
@Trace
28-
private void dispatch(RoutingContext routingContext, InputStream is, VertxOutput output) {
29-
HashMap<String, Object> attributes = new HashMap<String, Object>();
30-
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", routingContext.normalizedPath());
31-
Utils.addRoute(attributes, routingContext.currentRoute());
32-
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
33-
Weaver.callOriginal();
34-
}
17+
@Trace
18+
public void handle(RoutingContext request) {
19+
HashMap<String, Object> attributes = new HashMap<String, Object>();
20+
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", request.normalizedPath());
21+
Utils.addRoute(attributes, request.currentRoute());
22+
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
23+
Utils.setTransactionName(request);
24+
Weaver.callOriginal();
25+
}
26+
27+
@Trace
28+
private void dispatch(RoutingContext routingContext, InputStream is, VertxOutput output) {
29+
HashMap<String, Object> attributes = new HashMap<String, Object>();
30+
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", routingContext.normalizedPath());
31+
Utils.addRoute(attributes, routingContext.currentRoute());
32+
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
33+
34+
Weaver.callOriginal();
35+
}
3536

3637
}

quarkus-resteasy-2.11/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies {
1515

1616
jar {
1717
manifest {
18-
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.quarkus-resteasy-2.0'
18+
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.quarkus-resteasy-2.11.0'
1919
attributes 'Implementation-Vendor': 'New Relic Labs'
2020
attributes 'Implementation-Vendor-Id': 'com.newrelic.labs'
2121
attributes 'Implementation-Version': 1.0

quarkus-resteasy-2.11/src/main/java/com/newrelic/instrumentation/quarkus/resteasy/Utils.java

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,46 @@
22

33
import java.util.Map;
44

5+
import com.newrelic.api.agent.NewRelic;
6+
import com.newrelic.api.agent.TransactionNamePriority;
7+
58
import io.vertx.ext.web.Route;
9+
import io.vertx.ext.web.RoutingContext;
610

711
public class Utils {
812

9-
public static final String NEWRELIC_TOKEN = "NewRelic-Token";
10-
11-
public static void addAttribute(Map<String, Object> attributes, String key, Object value) {
12-
if(attributes != null && key != null && !key.isEmpty() && value != null) {
13-
attributes.put(key, value);
14-
}
13+
public static final String NEWRELIC_TOKEN = "NewRelic-Token";
14+
15+
public static void addAttribute(Map<String, Object> attributes, String key, Object value) {
16+
if (attributes != null && key != null && !key.isEmpty() && value != null) {
17+
attributes.put(key, value);
18+
}
19+
}
20+
21+
public static void addRoute(Map<String, Object> attributes, Route route) {
22+
if (route != null) {
23+
addAttribute(attributes, "Route-Name", route.getName());
24+
addAttribute(attributes, "Route-Path", route.getPath());
1525
}
16-
17-
public static void addRoute(Map<String, Object> attributes, Route route) {
18-
if(route != null) {
19-
addAttribute(attributes, "Route-Name", route.getName());
20-
addAttribute(attributes, "Route-Path", route.getPath());
21-
}
26+
}
27+
28+
public static void setTransactionName(RoutingContext request) {
29+
String name = " ";
30+
String route = request.currentRoute().getName();
31+
if (route != null & route.length() > 0) {
32+
name += route;
33+
}
34+
String path = request.currentRoute().getPath();
35+
if (path != null & path.length() > 0) {
36+
name += ":" + path;
2237
}
38+
String method = request.request().method().name();
39+
if (method != null & method.length() > 0) {
40+
name += " (" + method + ")";
41+
}
42+
System.out.println(name);
43+
NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, false, "Quarkus",
44+
"resteasy", name);
45+
46+
}
2347
}

quarkus-resteasy-2.11/src/main/java/io/quarkus/resteasy/runtime/standalone/RequestDispatcher.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
@Weave
1515
public abstract class RequestDispatcher {
1616

17-
@Trace
18-
public void service(Context context,
19-
HttpServerRequest req,
20-
HttpServerResponse resp,
21-
HttpRequest vertxReq, HttpResponse vertxResp, boolean handleNotFound) {
22-
Weaver.callOriginal();
23-
}
17+
@Trace
18+
public void service(Context context, HttpServerRequest req, HttpServerResponse resp, HttpRequest vertxReq,
19+
HttpResponse vertxResp, boolean handleNotFound) {
20+
21+
Weaver.callOriginal();
22+
}
2423
}

quarkus-resteasy-2.11/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxRequestHandler.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,24 @@
1414
@Weave
1515
public class VertxRequestHandler {
1616

17-
@Trace
18-
public void handle(RoutingContext request) {
19-
HashMap<String, Object> attributes = new HashMap<String, Object>();
20-
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", request.normalizedPath());
21-
Utils.addRoute(attributes, request.currentRoute());
22-
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
23-
24-
Weaver.callOriginal();
25-
}
26-
27-
@Trace
28-
private void dispatch(RoutingContext routingContext, InputStream is, VertxOutput output) {
29-
HashMap<String, Object> attributes = new HashMap<String, Object>();
30-
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", routingContext.normalizedPath());
31-
Utils.addRoute(attributes, routingContext.currentRoute());
32-
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
33-
Weaver.callOriginal();
34-
}
17+
@Trace
18+
public void handle(RoutingContext request) {
19+
HashMap<String, Object> attributes = new HashMap<String, Object>();
20+
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", request.normalizedPath());
21+
Utils.addRoute(attributes, request.currentRoute());
22+
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
23+
Utils.setTransactionName(request);
24+
Weaver.callOriginal();
25+
}
26+
27+
@Trace
28+
private void dispatch(RoutingContext routingContext, InputStream is, VertxOutput output) {
29+
HashMap<String, Object> attributes = new HashMap<String, Object>();
30+
Utils.addAttribute(attributes, "RoutingContext-NormalizedPath", routingContext.normalizedPath());
31+
Utils.addRoute(attributes, routingContext.currentRoute());
32+
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes);
33+
34+
Weaver.callOriginal();
35+
}
3536

3637
}

quarkus-resteasy-2.14.1/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies {
1515

1616
jar {
1717
manifest {
18-
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.quarkus-resteasy-2.0'
18+
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.quarkus-resteasy-2.14.1'
1919
attributes 'Implementation-Vendor': 'New Relic Labs'
2020
attributes 'Implementation-Vendor-Id': 'com.newrelic.labs'
2121
attributes 'Implementation-Version': 1.0

quarkus-resteasy-2.14.1/src/main/java/com/newrelic/instrumentation/quarkus/resteasy/Utils.java

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,46 @@
22

33
import java.util.Map;
44

5+
import com.newrelic.api.agent.NewRelic;
6+
import com.newrelic.api.agent.TransactionNamePriority;
7+
58
import io.vertx.ext.web.Route;
9+
import io.vertx.ext.web.RoutingContext;
610

711
public class Utils {
812

9-
public static final String NEWRELIC_TOKEN = "NewRelic-Token";
10-
11-
public static void addAttribute(Map<String, Object> attributes, String key, Object value) {
12-
if(attributes != null && key != null && !key.isEmpty() && value != null) {
13-
attributes.put(key, value);
14-
}
13+
public static final String NEWRELIC_TOKEN = "NewRelic-Token";
14+
15+
public static void addAttribute(Map<String, Object> attributes, String key, Object value) {
16+
if (attributes != null && key != null && !key.isEmpty() && value != null) {
17+
attributes.put(key, value);
18+
}
19+
}
20+
21+
public static void addRoute(Map<String, Object> attributes, Route route) {
22+
if (route != null) {
23+
addAttribute(attributes, "Route-Name", route.getName());
24+
addAttribute(attributes, "Route-Path", route.getPath());
1525
}
16-
17-
public static void addRoute(Map<String, Object> attributes, Route route) {
18-
if(route != null) {
19-
addAttribute(attributes, "Route-Name", route.getName());
20-
addAttribute(attributes, "Route-Path", route.getPath());
21-
}
26+
}
27+
28+
public static void setTransactionName(RoutingContext request) {
29+
String name = " ";
30+
String route = request.currentRoute().getName();
31+
if (route != null & route.length() > 0) {
32+
name += route;
33+
}
34+
String path = request.currentRoute().getPath();
35+
if (path != null & path.length() > 0) {
36+
name += ":" + path;
2237
}
38+
String method = request.request().method().name();
39+
if (method != null & method.length() > 0) {
40+
name += " (" + method + ")";
41+
}
42+
System.out.println(name);
43+
NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, false, "Quarkus",
44+
"resteasy", name);
45+
46+
}
2347
}

quarkus-resteasy-2.14.1/src/main/java/io/quarkus/resteasy/runtime/standalone/RequestDispatcher.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
@Weave
1616
public abstract class RequestDispatcher {
1717

18-
@Trace
19-
public void service(Context context,
20-
HttpServerRequest req,
21-
HttpServerResponse resp,
22-
HttpRequest vertxReq, HttpResponse vertxResp, boolean handleNotFound, Throwable t) {
23-
if(t != null) {
24-
NewRelic.noticeError(t);
25-
}
26-
Weaver.callOriginal();
18+
@Trace
19+
public void service(Context context, HttpServerRequest req, HttpServerResponse resp, HttpRequest vertxReq,
20+
HttpResponse vertxResp, boolean handleNotFound, Throwable t) {
21+
if (t != null) {
22+
NewRelic.noticeError(t);
2723
}
24+
25+
Weaver.callOriginal();
26+
}
2827
}

0 commit comments

Comments
 (0)