Skip to content

Commit 3fd351a

Browse files
committed
readme update with install and configure instructions. support for bintray deployments
1 parent 6906d6e commit 3fd351a

File tree

4 files changed

+122
-16
lines changed

4 files changed

+122
-16
lines changed

README.md

+22-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,28 @@ This project aims at providing an alternate parameter whitelist with support for
1010
Services added in the provided parameter whitelist:
1111
* S3 - Request parameters: BucketName, Key, VersionId, Prefix
1212

13+
Parameter whitelist file is available: [here](https://github.com/functionalone/aws-xray-parameter-whitelist-java/blob/master/src/main/resources/com/github/functionalone/xray/handlers/ExtendedOperationParameterWhitelist.json).
14+
1315
# Installation
1416

15-
Project provides a drop-in replacement jar which should be used instead of the AWS X-Ray SDK jar of: `aws-xray-recorder-sdk-aws-sdk-instrumentor`. The project jar includes the alternate configuration for the X-Ray tracing request handler.
17+
Project provides a drop-in replacement jar which should be used instead of the AWS X-Ray SDK jar of: `aws-xray-recorder-sdk-aws-sdk-instrumentor`. The project jar includes the alternate configuration for the X-Ray tracing request handler. This means that you can simply use the provided jar without any source code modifications, same way as the original `aws-xray-recorder-sdk-aws-sdk-instrumentor` is used.
1618

1719
## Adding the Jar as a Dependency
1820

19-
Stay tuned. We are still in the process of publishing the project to JCenter.
21+
Build artifacts are available via Bintray's JCenter. Project binary distributions are available at: https://bintray.com/functionalone/maven/aws-xray-parameter-whitelist-instrumentor. To add the jar as a dependency, you will need to use the jcenter repository. For example, if you are using Gradle you will need to add the following section to the repositories closure:
22+
23+
```
24+
repositories {
25+
jcenter()
26+
}
27+
```
28+
29+
And then add the following compilation dependency:
30+
```
31+
compile 'com.github.functionalone:aws-xray-parameter-whitelist-instrumentor:<version>'
32+
```
33+
34+
Make sure to remove the `aws-xray-recorder-sdk-aws-sdk-instrumentor` compile dependency.
2035

2136
## Compiling from Source
2237

@@ -27,4 +42,9 @@ Clone (or download) the project. Then run:
2742
```
2843
Target jar will be created at: `build/lib`. Jar will be named: `aws-xray-parameter-whitelist-instrumentor-<version>.jar`. Add the jar to your application classpath and make sure to remove: `aws-xray-recorder-sdk-aws-sdk-instrumentor`.
2944

45+
# Parameter Whitelist Configuration
46+
47+
It is possible to configure a custom parameter whitelist file instead of the default one provided with the package. This can be done either via a the environment variable: `AWS_XRAY_WHITELIST_URL` or the System property: `alt.aws.xray.whitelist.url`. The System property takes precedence over the environment variable. Value should be set to a resource path as specified by [Class.getResource()](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getResource-java.lang.String-). For example: `/com/myconpany/mypackage/MyParameterWhitelist.json`.
48+
49+
**Note**: If setting the System property programmatically, you need to set this before using the AWS SDK. The configuration is evaluated once upon first usage of the AWS SDK.
3050

build.gradle

+94-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
buildscript {
2+
repositories {
3+
jcenter()
4+
}
5+
dependencies {
6+
classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3")
7+
}
8+
}
9+
110
apply plugin: 'java-library'
211
apply plugin: 'eclipse'
12+
apply plugin: 'maven-publish'
13+
apply plugin: 'com.jfrog.bintray'
14+
315

416
// In this section you declare where to find the dependencies of your project
517
repositories {
@@ -8,10 +20,12 @@ repositories {
820
jcenter()
921
}
1022

23+
version = '0.1.1'
24+
1125
sourceCompatibility = 1.8
1226
targetCompatibility = 1.8
1327

14-
archivesBaseName = 'aws-xray-parameter-whitelist-instrumentor'
28+
1529

1630
dependencies {
1731
// This dependency is exported to consumers, that is to say found on their compile classpath.
@@ -27,14 +41,92 @@ dependencies {
2741
)
2842
}
2943

44+
archivesBaseName = 'aws-xray-parameter-whitelist-instrumentor'
45+
def githubUrl = 'https://github.com/functionalone/aws-xray-parameter-whitelist-java'
46+
47+
task sourceJar(type: Jar) {
48+
classifier = 'sources'
49+
from sourceSets.main.allSource
50+
}
51+
52+
task javadocJar(type: Jar, dependsOn: javadoc) {
53+
classifier = 'javadoc'
54+
from javadoc.destinationDir
55+
}
56+
57+
// Create the pom configuration:
58+
def pomConfig = {
59+
licenses {
60+
license {
61+
name "MIT"
62+
url "https://opensource.org/licenses/MIT"
63+
distribution "repo"
64+
}
65+
}
66+
scm {
67+
url githubUrl
68+
}
69+
}
70+
71+
publishing {
72+
publications {
73+
MyPublication(MavenPublication) {
74+
from components.java
75+
artifact sourceJar
76+
artifact javadocJar
77+
groupId 'com.github.functionalone'
78+
artifactId project.archivesBaseName
79+
version project.version
80+
pom.withXml {
81+
def root = asNode()
82+
root.appendNode('description', 'Configure AWS X-Ray (Java) with an alternate parameter whitelist')
83+
root.appendNode('name', project.archivesBaseName)
84+
root.appendNode('url', githubUrl)
85+
root.children().last() + pomConfig
86+
}
87+
}
88+
}
89+
}
90+
91+
92+
model {
93+
tasks.generatePomFileForMyPublicationPublication {
94+
destination = file("$buildDir/libs/${project.archivesBaseName}-${project.version}.pom")
95+
}
96+
}
97+
98+
99+
bintray {
100+
user = System.getProperty("bintray.user")
101+
key = System.getProperty("bintray.api_key")
102+
publications = ['MyPublication']
103+
publish = true //[Default: false] Whether version should be auto published after an upload
104+
pkg {
105+
repo = 'maven'
106+
name = project.archivesBaseName
107+
userOrg = 'functionalone'
108+
desc = 'Configure AWS X-Ray (Java) with an alternate parameter whitelist'
109+
licenses = ['MIT']
110+
vcsUrl = githubUrl
111+
labels = ['aws', 'xray', 'whitelist']
112+
publicDownloadNumbers = false
113+
version {
114+
name = project.version
115+
desc = project.version
116+
vcsTag = 'master'
117+
//attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin']
118+
}
119+
}
120+
}
121+
30122
test {
31123
testLogging {
32124
events "passed", "skipped", "failed"
33125
}
34126
systemProperty "aws-xray-whitelist.s3-bucket", System.getProperty("aws-xray-whitelist.s3-bucket")
35127
}
36128

37-
version = '0.1.0'
129+
38130

39131
jar {
40132
manifest {

settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ include 'api'
1515
include 'services:webservice'
1616
*/
1717

18-
rootProject.name = 'aws-xray-whitelist-java'
18+
rootProject.name = 'aws-xray-parameter-whitelist-java'

src/main/java/com/github/functionalone/xray/handlers/TracingHandlerExtended.java

+5-11
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ private static URL newUrlWithLog(String s) {
3232
return null;
3333
}
3434
try {
35-
URL res = new URL(s);
36-
logger.info("Whitelist url set to: " + s);
35+
URL res = TracingHandler.class.getResource(s);
36+
logger.debug("Whitelist url set to: " + res);
3737
return res;
3838
} catch (Exception e) {
3939
logger.error("Failed setting whitelist url with value: [" + s + "].", e);
@@ -43,9 +43,9 @@ private static URL newUrlWithLog(String s) {
4343

4444
/**
4545
* Will try to resolve in this order:
46-
* - system property: aws-xray-whitelist.url
46+
* - system property: alt.aws.xray.whitelist.url
4747
* - environment property: AWS_XRAY_WHITELIST_URL
48-
* - default: resource:/com/github/functionalone/xray/handlers/ExtendedOperationParameterWhitelist.json
48+
* - default: resource: /com/github/functionalone/xray/handlers/ExtendedOperationParameterWhitelist.json
4949
* @return the found url or null if there is a problem
5050
*/
5151
private static URL getConfiguredWhitelistUrl() {
@@ -57,13 +57,7 @@ private static URL getConfiguredWhitelistUrl() {
5757
if(null != res) {
5858
return res;
5959
}
60-
//use default
61-
try {
62-
return TracingHandler.class.getResource(DEFAULT_WHITELIST_RESOURCE_URL);
63-
} catch (Exception e) {
64-
logger.error("Failed getting url resource of default whitelist url: " + DEFAULT_WHITELIST_RESOURCE_URL, e);
65-
}
66-
return null;
60+
return newUrlWithLog(DEFAULT_WHITELIST_RESOURCE_URL);
6761
}
6862

6963
private static final URL OPERATION_PARAMETER_WHITELIST = getConfiguredWhitelistUrl();

0 commit comments

Comments
 (0)