generated from newrelic-experimental/java-instrumentation-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
1,648 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
.java-version | ||
.git | ||
.github | ||
.classpath | ||
.project | ||
.settings | ||
build | ||
bin |
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,30 @@ | ||
|
||
// Build.gradle generated for instrumentation module netflix-zuul-core-1.x | ||
|
||
apply plugin: 'java' | ||
|
||
dependencies { | ||
implementation group: 'com.netflix.zuul', name: 'zuul-core', version: '1.2.0' | ||
compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0' | ||
|
||
|
||
// New Relic Java Agent dependencies | ||
implementation 'com.newrelic.agent.java:newrelic-agent:6.4.0' | ||
implementation 'com.newrelic.agent.java:newrelic-api:6.4.0' | ||
implementation fileTree(include: ['*.jar'], dir: '../libs') | ||
implementation fileTree(include: ['*.jar'], dir: '../test-lib') | ||
} | ||
|
||
jar { | ||
manifest { | ||
attributes 'Implementation-Title': 'com.newrelic.instrumentation.netflix-zuul-core-1.x' | ||
attributes 'Implementation-Vendor': 'New Relic' | ||
attributes 'Implementation-Vendor-Id': 'com.newrelic' | ||
attributes 'Implementation-Version': 1.0 | ||
} | ||
} | ||
|
||
verifyInstrumentation { | ||
passes 'com.netflix.zuul:zuul-core:[1.2.0,2.1.1)' | ||
excludeRegex '.*rc.[1-9]' | ||
} |
24 changes: 24 additions & 0 deletions
24
netflix-zuul-core-1.x/src/main/java/com/netflix/zuul/FilterProcessor.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,24 @@ | ||
package com.netflix.zuul; | ||
|
||
import com.newrelic.api.agent.Trace; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
|
||
@Weave | ||
public abstract class FilterProcessor { | ||
|
||
@Trace | ||
public void preRoute() { | ||
Weaver.callOriginal(); | ||
} | ||
|
||
@Trace | ||
public void route() { | ||
Weaver.callOriginal(); | ||
} | ||
|
||
@Trace | ||
public void postRoute() { | ||
Weaver.callOriginal(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
netflix-zuul-core-1.x/src/main/java/com/netflix/zuul/IZuulFilter.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,20 @@ | ||
package com.netflix.zuul; | ||
|
||
import com.newrelic.api.agent.NewRelic; | ||
import com.newrelic.api.agent.Trace; | ||
import com.newrelic.api.agent.TracedMethod; | ||
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) | ||
public abstract class IZuulFilter { | ||
|
||
@Trace | ||
public Object run() { | ||
TracedMethod traced = NewRelic.getAgent().getTracedMethod(); | ||
traced.setMetricName("Custom","Zuul","ZuulFilter",getClass().getSimpleName(),"run"); | ||
return Weaver.callOriginal(); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
netflix-zuul-core-1.x/src/main/java/com/netflix/zuul/ZuulFilter.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,32 @@ | ||
package com.netflix.zuul; | ||
|
||
import com.newrelic.api.agent.NewRelic; | ||
import com.newrelic.api.agent.Trace; | ||
import com.newrelic.api.agent.TracedMethod; | ||
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 abstract class ZuulFilter { | ||
|
||
public abstract String filterType(); | ||
|
||
@Trace | ||
public ZuulFilterResult runFilter() { | ||
TracedMethod traced = NewRelic.getAgent().getTracedMethod(); | ||
traced.setMetricName("Custom","Zuul","ZuulFilter",getClass().getSimpleName(),"runFilter"); | ||
traced.addCustomAttribute("FilterType", filterType()); | ||
ZuulFilterResult fResult = Weaver.callOriginal(); | ||
String status = fResult != null ? fResult.getStatus() != null ? fResult.getStatus().name() : null : null; | ||
if(status != null) { | ||
traced.addCustomAttribute("FilterResult",status); | ||
} | ||
Throwable t = fResult != null ? fResult.getException() : null; | ||
if(t != null) { | ||
NewRelic.noticeError(t); | ||
} | ||
return fResult; | ||
} | ||
|
||
} |
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,28 @@ | ||
|
||
// Build.gradle generated for instrumentation module netflix-zuul-core-2.1 | ||
|
||
apply plugin: 'java' | ||
|
||
dependencies { | ||
implementation 'com.netflix.zuul:zuul-core:2.1.6' | ||
implementation group: 'io.netty', name: 'netty-tcnative-boringssl-static', version: '2.0.7.Final' | ||
|
||
// New Relic Java Agent dependencies | ||
implementation 'com.newrelic.agent.java:newrelic-agent:6.4.0' | ||
implementation 'com.newrelic.agent.java:newrelic-api:6.4.0' | ||
implementation fileTree(include: ['*.jar'], dir: '../libs') | ||
implementation fileTree(include: ['*.jar'], dir: '../test-lib') | ||
} | ||
|
||
jar { | ||
manifest { | ||
attributes 'Implementation-Title': 'com.newrelic.instrumentation.netflix-zuul-core-2.1.6' | ||
attributes 'Implementation-Vendor': 'New Relic' | ||
attributes 'Implementation-Vendor-Id': 'com.newrelic' | ||
attributes 'Implementation-Version': 1.0 | ||
} | ||
} | ||
|
||
verifyInstrumentation { | ||
passes 'com.netflix.zuul:zuul-core:[2.1.6,)' | ||
} |
40 changes: 40 additions & 0 deletions
40
...-core-2.1.6/src/main/java/com/netflix/netty/common/HttpClientLifecycleChannelHandler.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,40 @@ | ||
package com.netflix.netty.common; | ||
|
||
import com.newrelic.api.agent.Trace; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
|
||
import io.netty.channel.ChannelHandlerContext_Instrumentation; | ||
import io.netty.channel.ChannelPromise; | ||
|
||
@Weave | ||
public abstract class HttpClientLifecycleChannelHandler { | ||
|
||
@Weave | ||
private static class HttpClientLifecycleInboundChannelHandler { | ||
|
||
@Trace(async = true) | ||
public void channelRead(ChannelHandlerContext_Instrumentation ctx, Object msg) { | ||
if(ctx.pipeline().zuul_token != null) { | ||
ctx.pipeline().zuul_token.link(); | ||
} | ||
|
||
Weaver.callOriginal(); | ||
} | ||
|
||
} | ||
|
||
@Weave | ||
private static class HttpClientLifecycleOutboundChannelHandler { | ||
|
||
@Trace(async = true) | ||
public void write(ChannelHandlerContext_Instrumentation ctx, Object msg, ChannelPromise promise) { | ||
if(ctx.pipeline().zuul_token != null) { | ||
ctx.pipeline().zuul_token.link(); | ||
} | ||
Weaver.callOriginal(); | ||
|
||
} | ||
|
||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...6/src/main/java/com/netflix/netty/common/HttpLifecycleChannelHandler_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,49 @@ | ||
package com.netflix.netty.common; | ||
|
||
import com.netflix.netty.common.HttpLifecycleChannelHandler.CompleteReason; | ||
import com.newrelic.api.agent.NewRelic; | ||
import com.newrelic.api.agent.Token; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
import com.newrelic.instrumentation.labs.netflix_zuul.NettyRequestHeaders; | ||
import com.newrelic.instrumentation.labs.netflix_zuul.ZuulDispatcher; | ||
|
||
import io.netty.channel.ChannelHandlerContext_Instrumentation; | ||
import io.netty.handler.codec.http.HttpRequest; | ||
|
||
@Weave(originalName = "com.netflix.netty.common.HttpLifecycleChannelHandler") | ||
public abstract class HttpLifecycleChannelHandler_instrumentation { | ||
|
||
|
||
protected static boolean fireCompleteEventIfNotAlready(ChannelHandlerContext_Instrumentation ctx, CompleteReason reason) { | ||
boolean b = Weaver.callOriginal(); | ||
if(b) { | ||
if(ctx.pipeline().zuul_token != null) { | ||
ctx.pipeline().zuul_token.expire(); | ||
ctx.pipeline().zuul_token = null; | ||
} | ||
} | ||
|
||
return b; | ||
} | ||
|
||
protected static boolean fireStartEvent(ChannelHandlerContext_Instrumentation ctx, HttpRequest request) { | ||
boolean b = Weaver.callOriginal(); | ||
if(b) { | ||
ZuulDispatcher.get().channelRead(ctx, request); | ||
NettyRequestHeaders headers = new NettyRequestHeaders(request); | ||
NewRelic.getAgent().getTransaction().insertDistributedTraceHeaders(headers); | ||
if(ctx.pipeline().zuul_token == null) { | ||
Token t = NewRelic.getAgent().getTransaction().getToken(); | ||
if(t != null && t.isActive()) { | ||
ctx.pipeline().zuul_token= t; | ||
} else if(t != null) { | ||
t.expire(); | ||
t = null; | ||
} | ||
} | ||
} | ||
|
||
return b; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...-core-2.1.6/src/main/java/com/netflix/netty/common/HttpServerLifecycleChannelHandler.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,38 @@ | ||
package com.netflix.netty.common; | ||
|
||
import com.newrelic.api.agent.Trace; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
|
||
import io.netty.channel.ChannelHandlerContext_Instrumentation; | ||
import io.netty.channel.ChannelPromise; | ||
|
||
@Weave | ||
public abstract class HttpServerLifecycleChannelHandler { | ||
|
||
@Weave | ||
public static class HttpServerLifecycleInboundChannelHandler { | ||
|
||
@Trace(async = true) | ||
public void channelRead(ChannelHandlerContext_Instrumentation ctx, Object msg) { | ||
if(ctx.pipeline().zuul_token != null) { | ||
ctx.pipeline().zuul_token.link(); | ||
} | ||
Weaver.callOriginal(); | ||
} | ||
|
||
} | ||
|
||
@Weave | ||
public static class HttpServerLifecycleOutboundChannelHandler { | ||
|
||
@Trace(async = true) | ||
public void write(ChannelHandlerContext_Instrumentation ctx, Object msg, ChannelPromise promise) { | ||
if(ctx.pipeline().zuul_token != null) { | ||
ctx.pipeline().zuul_token.link(); | ||
} | ||
Weaver.callOriginal(); | ||
} | ||
|
||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
netflix-zuul-core-2.1.6/src/main/java/com/netflix/zuul/RequestCompleteHandler.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,27 @@ | ||
package com.netflix.zuul; | ||
|
||
import java.util.HashMap; | ||
|
||
import com.netflix.zuul.message.http.HttpRequestInfo; | ||
import com.netflix.zuul.message.http.HttpResponseMessage; | ||
import com.newrelic.api.agent.NewRelic; | ||
import com.newrelic.api.agent.Trace; | ||
import com.newrelic.api.agent.TracedMethod; | ||
import com.newrelic.api.agent.weaver.MatchType; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
import com.newrelic.instrumentation.labs.netflix_zuul.Utils; | ||
|
||
@Weave(type = MatchType.Interface) | ||
public class RequestCompleteHandler { | ||
|
||
@Trace | ||
public void handle(HttpRequestInfo inboundRequest, HttpResponseMessage response) { | ||
TracedMethod traced = NewRelic.getAgent().getTracedMethod(); | ||
HashMap<String, Object> attributes = new HashMap<>(); | ||
Utils.addRequestInfo(attributes, inboundRequest); | ||
traced.addCustomAttribute("In", inboundRequest.getMethod()); | ||
traced.setMetricName("Custom","Netflix","Zuul","RequestCompleteHandler",getClass().getSimpleName(),"handle"); | ||
Weaver.callOriginal(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
netflix-zuul-core-2.1.6/src/main/java/com/netflix/zuul/filters/SyncZuulFilter.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,24 @@ | ||
package com.netflix.zuul.filters; | ||
|
||
import com.netflix.zuul.message.ZuulMessage; | ||
import com.newrelic.api.agent.NewRelic; | ||
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) | ||
public abstract class SyncZuulFilter<I extends ZuulMessage, O extends ZuulMessage> implements ZuulFilter<I, O> { | ||
|
||
@Trace | ||
public O apply(I input) { | ||
String filterName = filterName(); | ||
if(filterName != null && !filterName.isEmpty()) { | ||
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Netflix-Zuul","SyncZuulFilter",filterName,"apply"); | ||
} else { | ||
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Netflix-Zuul","SyncZuulFilter",getClass().getSimpleName(),"apply"); | ||
} | ||
return Weaver.callOriginal(); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
...ix-zuul-core-2.1.6/src/main/java/com/netflix/zuul/filters/ZuulFilter_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,35 @@ | ||
package com.netflix.zuul.filters; | ||
|
||
import java.util.Hashtable; | ||
|
||
import com.netflix.zuul.message.ZuulMessage; | ||
import com.newrelic.api.agent.NewRelic; | ||
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; | ||
|
||
import rx.Observable; | ||
|
||
@Weave(type=MatchType.Interface, originalName = "com.netflix.zuul.filters.ZuulFilter") | ||
public abstract class ZuulFilter_instrumentation<I extends ZuulMessage, O extends ZuulMessage> { | ||
|
||
public abstract FilterSyncType getSyncType(); | ||
public abstract String filterName(); | ||
public abstract FilterType filterType(); | ||
|
||
@Trace | ||
public Observable<O> applyAsync(I input) { | ||
String filterName = filterName(); | ||
if(filterName != null && !filterName.isEmpty()) { | ||
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Netflix-Zuul","ZuulFilter",filterName,"applyAsync"); | ||
} else { | ||
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Netflix-Zuul","ZuulFilter",getClass().getSimpleName(),"applyAsync"); | ||
} | ||
Hashtable<String, Object> attributes = new Hashtable<>(); | ||
attributes.put("Filter-Synctype", getSyncType()); | ||
attributes.put("FilterType", filterType()); | ||
NewRelic.getAgent().getTracedMethod().addCustomAttributes(attributes); | ||
return Weaver.callOriginal(); | ||
} | ||
} |
Oops, something went wrong.