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.
base version of Jetty-Clojure and Ring
- Loading branch information
1 parent
bc61487
commit 2dce0ac
Showing
18 changed files
with
722 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,4 @@ | ||
.java-version | ||
.git | ||
.github | ||
/.metadata/ |
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,94 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="output" path="bin/default"/> | ||
<classpathentry output="bin/main" kind="src" path="src/main/java"> | ||
<attributes> | ||
<attribute name="gradle_scope" value="main"/> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry output="bin/test" kind="src" path="src/test/java"> | ||
<attributes> | ||
<attribute name="gradle_scope" value="test"/> | ||
<attribute name="gradle_used_by_scope" value="test"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/> | ||
<classpathentry sourcepath="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/org.eclipse.jetty/jetty-server/9.4.12.v20180830/712340530c033db88c90be6d9b89dad432af07ea/jetty-server-9.4.12.v20180830-sources.jar" kind="lib" path="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/org.eclipse.jetty/jetty-server/9.4.12.v20180830/b0f25df0d32a445fd07d5f16fff1411c16b888fa/jetty-server-9.4.12.v20180830.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry sourcepath="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/com.newrelic.agent.java/newrelic-agent/6.4.0/e640c171a471a3cf07a6ab7c248640ffc9e10953/newrelic-agent-6.4.0-sources.jar" kind="lib" path="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/com.newrelic.agent.java/newrelic-agent/6.4.0/716c0521d4baa12d9f2b0a005e1ee06a9c180214/newrelic-agent-6.4.0.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry sourcepath="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/com.newrelic.agent.java/newrelic-api/6.4.0/3f31215c788ccdbee6caecdfd9aabec579b84019/newrelic-api-6.4.0-sources.jar" kind="lib" path="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/com.newrelic.agent.java/newrelic-api/6.4.0/d0e5901678a35d963ba3855edbcaf9fc530c4bc0/newrelic-api-6.4.0.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry sourcepath="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/javax.servlet/javax.servlet-api/3.1.0/ab3976d4574c48d22dc1abf6a9e8bd0fdf928223/javax.servlet-api-3.1.0-sources.jar" kind="lib" path="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/javax.servlet/javax.servlet-api/3.1.0/3cd63d075497751784b2fa84be59432f4905bf7c/javax.servlet-api-3.1.0.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry sourcepath="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/org.eclipse.jetty/jetty-http/9.4.12.v20180830/f81d12f4cd8092a20fa94ff6a3dda539c87b56e2/jetty-http-9.4.12.v20180830-sources.jar" kind="lib" path="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/org.eclipse.jetty/jetty-http/9.4.12.v20180830/1341796dde4e16df69bca83f3e87688ba2e7d703/jetty-http-9.4.12.v20180830.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry sourcepath="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/org.eclipse.jetty/jetty-io/9.4.12.v20180830/fd1ba72f65b9c940ae1552559876d9953f6b44be/jetty-io-9.4.12.v20180830-sources.jar" kind="lib" path="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/org.eclipse.jetty/jetty-io/9.4.12.v20180830/e93f5adaa35a9a6a85ba130f589c5305c6ecc9e3/jetty-io-9.4.12.v20180830.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry sourcepath="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/org.eclipse.jetty/jetty-util/9.4.12.v20180830/af01f7eb3e5b9019ebce9637810041dbf5e3560d/jetty-util-9.4.12.v20180830-sources.jar" kind="lib" path="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/org.eclipse.jetty/jetty-util/9.4.12.v20180830/cb4ccec9bd1fe4b10a04a0fb25d7053c1050188a/jetty-util-9.4.12.v20180830.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry sourcepath="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/org.nanohttpd/nanohttpd/2.3.1/c820129da77c30b2e4ea1cea619d7f589a17bcdd/nanohttpd-2.3.1-sources.jar" kind="lib" path="/Users/gsidhwani/.gradle/caches/modules-2/files-2.1/org.nanohttpd/nanohttpd/2.3.1/a8d54d1ca554a77f377eff6bf9e16ca8383c8f6c/nanohttpd-2.3.1.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="test"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="lib" path="/Users/gsidhwani/Documents/GitHub/Experimental/newrelic-java-clojure/libs/agent-bridge-datastore.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="lib" path="/Users/gsidhwani/Documents/GitHub/Experimental/newrelic-java-clojure/libs/agent-bridge.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="lib" path="/Users/gsidhwani/Documents/GitHub/Experimental/newrelic-java-clojure/libs/newrelic-agent-6.4.0.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="lib" path="/Users/gsidhwani/Documents/GitHub/Experimental/newrelic-java-clojure/libs/newrelic-weaver-scala-api.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="lib" path="/Users/gsidhwani/Documents/GitHub/Experimental/newrelic-java-clojure/libs/newrelic-weaver-api.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="lib" path="/Users/gsidhwani/Documents/GitHub/Experimental/newrelic-java-clojure/libs/newrelic-api.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="lib" path="/Users/gsidhwani/Documents/GitHub/Experimental/newrelic-java-clojure/test-lib/instrumentation-test.jar"> | ||
<attributes> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
</classpath> |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>Jetty-Clojure</name> | ||
<comment></comment> | ||
<projects/> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments/> | ||
</buildCommand> | ||
</buildSpec> | ||
<linkedResources/> | ||
<filteredResources/> | ||
</projectDescription> |
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,13 @@ | ||
# | ||
#Mon May 29 14:02:24 IST 2023 | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.source=1.8 | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error |
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,2 @@ | ||
/main/ | ||
/test/ |
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,33 @@ | ||
|
||
// Build.gradle generated for instrumentation module Jetty-Clojure | ||
|
||
apply plugin: 'java' | ||
|
||
dependencies { | ||
// Declare a dependency on each JAR you want to instrument | ||
// Example: | ||
// implementation 'javax.servlet:servlet-api:2.5' | ||
implementation 'org.eclipse.jetty:jetty-server:9.4.12.v20180830' | ||
// 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.labs.Jetty-Clojure' | ||
attributes 'Implementation-Vendor': 'New Relic Labs' | ||
attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' | ||
attributes 'Implementation-Version': 1.0 | ||
} | ||
} | ||
|
||
verifyInstrumentation { | ||
// Verifier plugin documentation: | ||
// https://github.com/newrelic/newrelic-gradle-verify-instrumentation | ||
// Example: | ||
// passes 'javax.servlet:servlet-api:[2.2,2.5]' | ||
// exclude 'javax.servlet:servlet-api:2.4.public_draft' | ||
} |
80 changes: 80 additions & 0 deletions
80
Jetty-Clojure/src/main/java/com/nr/instrumentation/jetty/server/NRJettyRequest.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,80 @@ | ||
package com.nr.instrumentation.jetty.server; | ||
|
||
import java.util.Enumeration; | ||
import java.util.logging.Level; | ||
|
||
import javax.servlet.http.Cookie; | ||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import com.newrelic.api.agent.ExtendedRequest; | ||
import com.newrelic.api.agent.HeaderType; | ||
import com.newrelic.api.agent.NewRelic; | ||
import com.nr.instrumentation.jetty.server.Utils.MatchesHolder; | ||
public class NRJettyRequest extends ExtendedRequest { | ||
|
||
private HttpServletRequest request = null; | ||
|
||
public NRJettyRequest(HttpServletRequest req) { | ||
request = req; | ||
} | ||
|
||
|
||
@Override | ||
public String getRequestURI() { | ||
String requestURI = request.getRequestURI(); | ||
MatchesHolder holder = Utils.matches(requestURI); | ||
if(holder.matches && holder.regex != null && !holder.regex.isEmpty()) { | ||
NewRelic.getAgent().getLogger().log(Level.FINE, "Value of getRequestURI is {0}", requestURI); | ||
requestURI = holder.regex; | ||
} | ||
NewRelic.getAgent().getLogger().log(Level.FINE, "Value of getRequestURI is {0}", requestURI); | ||
return requestURI; | ||
} | ||
|
||
@Override | ||
public String getRemoteUser() { | ||
return request.getRemoteUser(); | ||
} | ||
|
||
@Override | ||
public Enumeration getParameterNames() { | ||
return request.getParameterNames(); | ||
} | ||
|
||
@Override | ||
public String[] getParameterValues(String name) { | ||
return request.getParameterValues(name); | ||
} | ||
|
||
@Override | ||
public Object getAttribute(String name) { | ||
return request.getAttribute(name); | ||
} | ||
|
||
@Override | ||
public String getCookieValue(String name) { | ||
Cookie[] cookies = request.getCookies(); | ||
for(Cookie cookie : cookies) { | ||
if(cookie.getName().equalsIgnoreCase(name)) { | ||
return cookie.getValue(); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public HeaderType getHeaderType() { | ||
return HeaderType.HTTP; | ||
} | ||
|
||
@Override | ||
public String getHeader(String name) { | ||
return request.getHeader(name); | ||
} | ||
|
||
@Override | ||
public String getMethod() { | ||
return request.getMethod(); | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
Jetty-Clojure/src/main/java/com/nr/instrumentation/jetty/server/NRJettyResponse.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,46 @@ | ||
package com.nr.instrumentation.jetty.server; | ||
|
||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import com.newrelic.api.agent.ExtendedResponse; | ||
import com.newrelic.api.agent.HeaderType; | ||
|
||
public class NRJettyResponse extends ExtendedResponse { | ||
|
||
private HttpServletResponse response = null; | ||
|
||
public NRJettyResponse(HttpServletResponse resp) { | ||
response = resp; | ||
} | ||
|
||
@Override | ||
public int getStatus() throws Exception { | ||
return response.getStatus(); | ||
} | ||
|
||
@Override | ||
public String getStatusMessage() throws Exception { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getContentType() { | ||
return response.getContentType(); | ||
} | ||
|
||
@Override | ||
public HeaderType getHeaderType() { | ||
return HeaderType.HTTP; | ||
} | ||
|
||
@Override | ||
public void setHeader(String name, String value) { | ||
response.addHeader(name, value); | ||
} | ||
|
||
@Override | ||
public long getContentLength() { | ||
return response.getBufferSize(); | ||
} | ||
|
||
} |
Oops, something went wrong.