Skip to content

Commit 8c2c379

Browse files
committed
first checkin
1 parent 435c213 commit 8c2c379

File tree

15 files changed

+720
-44
lines changed

15 files changed

+720
-44
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.java-version
2+
.git
3+
.github
4+
build
5+
bin
6+
.project
7+
.classpath
8+
.settings

README.md

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,53 @@
11
[![New Relic Experimental header](https://github.com/newrelic/opensource-website/raw/master/src/images/categories/Experimental.png)](https://opensource.newrelic.com/oss-category/#new-relic-experimental)
22

3-
# [Project Name]
4-
![GitHub forks](https://img.shields.io/github/forks/newrelic-experimental/newrelic-experimental-FIT-template?style=social)
5-
![GitHub stars](https://img.shields.io/github/stars/newrelic-experimental/newrelic-experimental-FIT-template?style=social)
6-
![GitHub watchers](https://img.shields.io/github/watchers/newrelic-experimental/newrelic-experimental-FIT-template?style=social)
73

8-
![GitHub all releases](https://img.shields.io/github/downloads/newrelic-experimental/newrelic-experimental-FIT-template/total)
9-
![GitHub release (latest by date)](https://img.shields.io/github/v/release/newrelic-experimental/newrelic-experimental-FIT-template)
10-
![GitHub last commit](https://img.shields.io/github/last-commit/newrelic-experimental/newrelic-experimental-FIT-template)
11-
![GitHub Release Date](https://img.shields.io/github/release-date/newrelic-experimental/newrelic-experimental-FIT-template)
4+
![GitHub forks](https://img.shields.io/github/forks/newrelic-experimental/newrelic-java-?style=social)
5+
![GitHub stars](https://img.shields.io/github/stars/newrelic-experimental/newrelic-java-ws-rs-errors?style=social)
6+
![GitHub watchers](https://img.shields.io/github/watchers/newrelic-experimental/newrelic-java-ws-rs-errors?style=social)
127

8+
![GitHub all releases](https://img.shields.io/github/downloads/newrelic-experimental/newrelic-java-ws-rs-errors/total)
9+
![GitHub release (latest by date)](https://img.shields.io/github/v/release/newrelic-experimental/newrelic-java-ws-rs-errors)
10+
![GitHub last commit](https://img.shields.io/github/last-commit/newrelic-experimental/newrelic-java-ws-rs-errors)
11+
![GitHub Release Date](https://img.shields.io/github/release-date/newrelic-experimental/newrelic-java-ws-rs-errors)
1312

14-
![GitHub issues](https://img.shields.io/github/issues/newrelic-experimental/newrelic-experimental-FIT-template)
15-
![GitHub issues closed](https://img.shields.io/github/issues-closed/newrelic-experimental/newrelic-experimental-FIT-template)
16-
![GitHub pull requests](https://img.shields.io/github/issues-pr/newrelic-experimental/newrelic-experimental-FIT-template)
17-
![GitHub pull requests closed](https://img.shields.io/github/issues-pr-closed/newrelic-experimental/newrelic-experimental-FIT-template)
1813

14+
![GitHub issues](https://img.shields.io/github/issues/newrelic-experimental/newrelic-java-ws-rs-errors)
15+
![GitHub issues closed](https://img.shields.io/github/issues-closed/newrelic-experimental/newrelic-java-ws-rs-errors)
16+
![GitHub pull requests](https://img.shields.io/github/issues-pr/newrelic-experimental/newrelic-java-ws-rs-errors)
17+
![GitHub pull requests closed](https://img.shields.io/github/issues-pr-closed/newrelic-experimental/newrelic-java-ws-rs-errors)
1918

20-
>[Brief description - what is the project and value does it provide? How often should users expect to get releases? How is versioning set up? Where does this project want to go?]
2119

22-
## Value
20+
# New Relic Java Instrumentation for Errors in WS RS Framework
2321

24-
|Metrics | Events | Logs | Traces | Visualization | Automation |
25-
|:-:|:-:|:-:|:-:|:-:|:-:|
26-
|:white_check_mark:|:white_check_mark:|:x:|:white_check_mark:|:x:|:x:|
27-
28-
### List of Metrics,Events,Logs,Traces
29-
|Name | Type | Description |
30-
|:-:|:-:|:-:|
31-
|*metric.name* | Metric| *description*|
32-
|*event.name* | Event| *description*|
33-
|*log.name* | Log| *description*|
34-
|*trace.name*| Trace| *description*
35-
|---|---|---|
22+
Provides instrumentation for the WS RS framework. It will capture errors that are routed through ExceptionMapper interface
3623

3724
## Installation
3825

39-
> [Include a step-by-step procedure on how to get your code installed. Be sure to include any third-party dependencies that need to be installed separately]
40-
41-
## Getting Started
42-
43-
>[Simple steps to start working with the software similar to a "Hello World"]
44-
45-
## Usage
26+
This use this instrumentation.
27+
1. Download the latest release.
28+
2. In the New Relic Java Agent directory (directory containing newrelic.jar), create a directory named extensions if it doe not already exist.
29+
3. Copy the jars into the extensions directory.
30+
4. Restart the application.
4631

47-
>[**Optional** - Include more thorough instructions on how to use the software. This section might not be needed if the Getting Started section is enough. Remove this section if it's not needed.]
4832

4933
## Building
5034

51-
>[**Optional** - Include this section if users will need to follow specific instructions to build the software from source. Be sure to include any third party build dependencies that need to be installed separately. Remove this section if it's not needed.]
52-
53-
## Testing
54-
55-
>[**Optional** - Include instructions on how to run tests if we include tests with the codebase. Remove this section if it's not needed.]
35+
If you make changes to the instrumentation code and need to build the instrumentation jars, follow these steps
36+
1. Set environment variable NEW_RELIC_EXTENSIONS_DIR. Its value should be the directory where you want to build the jars (i.e. the extensions directory of the Java Agent).
37+
2. Build one or all of the jars.
38+
a. To build one jar, run the command: gradlew _moduleName_:clean _moduleName_:install
39+
b. To build all jars, run the command: gradlew clean install
40+
3. Restart the application
5641

5742
## Support
5843

5944
New Relic has open-sourced this project. This project is provided AS-IS WITHOUT WARRANTY OR DEDICATED SUPPORT. Issues and contributions should be reported to the project here on GitHub.
6045

6146
>We encourage you to bring your experiences and questions to the [Explorers Hub](https://discuss.newrelic.com) where our community members collaborate on solutions and new ideas.
6247
63-
6448
## Contributing
6549

66-
We encourage your contributions to improve [Project Name]! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project. If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at opensource@newrelic.com.
50+
We encourage your contributions to improve Salesforce Commerce Cloud for New Relic Browser! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project. If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at opensource@newrelic.com.
6751

6852
**A note about vulnerabilities**
6953

@@ -73,6 +57,4 @@ If you believe you have found a security vulnerability in this project or any of
7357

7458
## License
7559

76-
[Project Name] is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.
77-
78-
>[If applicable: [Project Name] also uses source code from third-party libraries. You can find full details on which libraries are used and the terms under which they are licensed in the third-party notices document.]
60+
New Relic Java Instrumentation for ws rs errors is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.

build.gradle

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
// Build.gradle for creating or installing new instrumentation modules
2+
3+
4+
// Global defaults - override here or in individual modules as needed.
5+
buildscript {
6+
repositories {
7+
flatDir dirs: 'template-lib'
8+
mavenLocal()
9+
mavenCentral()
10+
gradlePluginPortal()
11+
}
12+
13+
dependencies {
14+
classpath 'gradle-templates:gradle-templates:1.5'
15+
classpath 'com.newrelic.agent.java:gradle-verify-instrumentation-plugin:3.2'
16+
}
17+
}
18+
19+
plugins {
20+
id "de.undercouch.download" version "1.2"
21+
}
22+
23+
project.ext {
24+
group = 'com.newrelic.instrumentation'
25+
javaAgentVersion = '6.4.0'
26+
27+
// Aligned with minimum Java major version supported by latest Java Agent
28+
javaVersion = JavaVersion.VERSION_1_8
29+
30+
}
31+
32+
apply plugin: 'java'
33+
apply plugin: 'de.undercouch.download'
34+
35+
import templates.*
36+
import de.undercouch.gradle.tasks.download.Download
37+
38+
task getAgent(type: Download) {
39+
def rootProject = projectDir.path
40+
src 'https://repo1.maven.org/maven2/com/newrelic/agent/java/newrelic-agent/'+project.javaAgentVersion+'/newrelic-agent-'+project.javaAgentVersion+'.jar'
41+
dest projectDir.path+"/libs/newrelic-agent-"+project.javaAgentVersion+".jar"
42+
}
43+
44+
task extractJars(type: Copy) {
45+
46+
from zipTree(projectDir.path+"/libs/newrelic-agent-"+project.javaAgentVersion+".jar")
47+
into projectDir.path+"/libs"
48+
}
49+
50+
task cleanUp(type: Delete) {
51+
delete projectDir.path+'/libs/META-INF', projectDir.path+'/libs/com', projectDir.path+'/libs/mozilla'
52+
delete projectDir.path+'/libs/LICENSE', projectDir.path+'/libs/Log4j-events.dtd', projectDir.path+'/libs/THIRD_PARTY_NOTICES.md'
53+
delete fileTree(projectDir.path+'/libs') {
54+
include '**/*.xsd'
55+
include '**/*.xml'
56+
include '**/*.yml'
57+
include '**/*.properties'
58+
}
59+
}
60+
61+
task checkForDependencies(type: Exec) {
62+
environment "JAVAAGENTVERSION", javaAgentVersion
63+
def rootProject = projectDir.path
64+
def cmdLine = rootProject+'/newrelic-dependencies.sh'
65+
workingDir rootProject
66+
commandLine cmdLine
67+
68+
}
69+
70+
task buildIfNeeded {
71+
dependsOn checkForDependencies
72+
dependsOn jar
73+
tasks.findByName('jar').mustRunAfter 'checkForDependencies'
74+
}
75+
76+
task createModule {
77+
dependsOn checkForDependencies
78+
description = 'Generate project files for a new instrumentation module'
79+
group = 'New Relic'
80+
doLast {
81+
82+
def rootProject = projectDir.path
83+
84+
String projectGroup = TemplatesPlugin.prompt('Instrumentation Module Group (default: ' + project.ext.group + ') (Hit return to use default):\n')
85+
String projectName = TemplatesPlugin.prompt('Instrumentation Module Name:\n')
86+
87+
if (projectName == null) {
88+
throw new Exception("Please specify a valid module name.")
89+
} else {
90+
projectName = projectName.trim()
91+
}
92+
93+
if (projectGroup == null || projectGroup.trim() == '') {
94+
projectGroup = project.ext.group
95+
} else {
96+
projectGroup = projectGroup.trim()
97+
}
98+
99+
def projectLibDir = new File(rootProject+'/lib')
100+
101+
def projectPath = new File(projectName)
102+
if (projectPath.exists()) {
103+
throw new Exception(projectPath.path + ' already exists.')
104+
}
105+
106+
def projectJava = new File(projectPath, 'src/main/java')
107+
def projectTest = new File(projectPath, 'src/test/java')
108+
mkdir projectJava
109+
mkdir projectTest
110+
111+
ProjectTemplate.fromRoot(projectPath) {
112+
'build.gradle' '''
113+
// Build.gradle generated for instrumentation module PROJECT_NAME
114+
115+
apply plugin: 'java'
116+
117+
dependencies {
118+
// Declare a dependency on each JAR you want to instrument
119+
// Example:
120+
// implementation 'javax.servlet:servlet-api:2.5'
121+
122+
// New Relic Java Agent dependencies
123+
implementation 'com.newrelic.agent.java:newrelic-agent:JAVA_AGENT_VERSION'
124+
implementation 'com.newrelic.agent.java:newrelic-api:JAVA_AGENT_VERSION'
125+
implementation fileTree(include: ['*.jar'], dir: '../libs')
126+
implementation fileTree(include: ['*.jar'], dir: '../test-lib')
127+
}
128+
129+
jar {
130+
manifest {
131+
attributes 'Implementation-Title': 'PROJECT_GROUP.PROJECT_NAME'
132+
attributes 'Implementation-Vendor': 'New Relic'
133+
attributes 'Implementation-Vendor-Id': 'com.newrelic'
134+
attributes 'Implementation-Version': 1.0
135+
}
136+
}
137+
138+
verifyInstrumentation {
139+
// Verifier plugin documentation:
140+
// https://github.com/newrelic/newrelic-gradle-verify-instrumentation
141+
// Example:
142+
// passes 'javax.servlet:servlet-api:[2.2,2.5]'
143+
// exclude 'javax.servlet:servlet-api:2.4.public_draft'
144+
}'''.replace('PROJECT_GROUP', projectGroup)
145+
.replace('PROJECT_NAME', projectName)
146+
.replace('PROJECT_PATH', projectPath.path)
147+
.replace('JAVA_AGENT_VERSION', project.ext.javaAgentVersion)
148+
}
149+
150+
File settings = new File('settings.gradle')
151+
settings.append("include '$projectName'\n")
152+
println "Created module in $projectPath.path."
153+
}
154+
}
155+
156+
subprojects {
157+
repositories {
158+
mavenLocal()
159+
mavenCentral()
160+
}
161+
162+
apply plugin: 'java'
163+
apply plugin: 'eclipse'
164+
apply plugin: 'idea'
165+
apply plugin: 'com.newrelic.gradle-verify-instrumentation-plugin'
166+
167+
sourceCompatibility = project.javaVersion
168+
targetCompatibility = project.javaVersion
169+
170+
dependencies {
171+
testImplementation fileTree(dir: '../lib', include: "*.jar") // + project.javaAgentVersion
172+
testImplementation 'org.nanohttpd:nanohttpd:2.3.1'
173+
testImplementation 'com.newrelic.agent.java:newrelic-agent:' + project.javaAgentVersion
174+
}
175+
176+
task install(dependsOn: buildIfNeeded, type: Copy) {
177+
description = 'Copies compiled jar to the NEW_RELIC_EXTENSIONS_DIR.'
178+
group = 'New Relic'
179+
180+
def extDir = System.getenv("NEW_RELIC_EXTENSIONS_DIR") ?: " "
181+
182+
from jar
183+
into extDir
184+
}
185+
186+
compileJava.doFirst {
187+
tasks.findByName('checkForDependencies')
188+
}
189+
190+
install.doFirst {
191+
def extDir = System.getenv("NEW_RELIC_EXTENSIONS_DIR")
192+
if (extDir == null) {
193+
throw new Exception("Must set NEW_RELIC_EXTENSIONS_DIR.")
194+
}
195+
196+
if (extDir.startsWith("~" + File.separator)) {
197+
extDir = System.getProperty("user.home") + extDir.substring(1);
198+
}
199+
200+
if (!file(extDir).directory) {
201+
throw new Exception(extDir + "NEW_RELIC_EXTENSIONS_DIR, set as '" + extDir + "'is not a valid directory.")
202+
}
203+
}
204+
}

gradle/wrapper/gradle-wrapper.jar

57.5 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)