This repository has been archived by the owner on Jul 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 231
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
1 parent
2669bc3
commit e309a7e
Showing
31 changed files
with
1,546 additions
and
1 deletion.
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
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,4 +1,4 @@ | ||
|
||
-include jaeger-java-crossdock/rules.mk | ||
|
||
.PHONY: clean | ||
clean: | ||
|
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
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,6 @@ | ||
FROM maven:3.3-jdk-7 | ||
EXPOSE 8080-8082 | ||
|
||
ADD build/libs/jaeger-java-crossdock.jar / | ||
|
||
CMD ["java", "-jar", "jaeger-java-crossdock.jar"] |
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,66 @@ | ||
apply plugin: 'jacoco' | ||
apply plugin: 'com.github.kt3k.coveralls' | ||
apply plugin: 'com.github.johnrengelman.shadow' | ||
|
||
|
||
description = 'A jaeger instrumented java server meant for testing interoperability with different Jaeger clients through the use of crossdock (https://github.com/crossdock/crossdock)' | ||
ext.jacksonVersion = '2.7.4' | ||
shadowJar.archiveName = 'jaeger-java-crossdock.jar' | ||
|
||
dependencies { | ||
compile project(':jaeger-jaxrs2') | ||
|
||
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion | ||
compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-grizzly2-http', version: jerseyVersion | ||
compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-servlet', version: jerseyVersion | ||
compile group: 'org.glassfish.jersey.core', name: 'jersey-client', version: jerseyVersion | ||
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-json-jackson', version: jerseyVersion | ||
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-moxy', version: '2.12' | ||
compile group: 'javax.servlet', name: 'servlet-api', version: '2.5' | ||
compile group: 'com.uber.tchannel', name: 'tchannel-core', version: '0.4.1' | ||
|
||
|
||
// Testing Frameworks | ||
testCompile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.16' | ||
testCompile group: 'junit', name: 'junit', version: '4.12' | ||
} | ||
|
||
jacocoTestReport { | ||
reports { | ||
xml.enabled = true // coveralls plugin depends on xml format report | ||
html.enabled = true | ||
html.destination "${buildDir}/jacocoHtml" | ||
} | ||
|
||
afterEvaluate { | ||
classDirectories = files(classDirectories.files.collect { | ||
fileTree(dir: it, | ||
exclude: [ | ||
'**/*Test*', | ||
]) | ||
}) | ||
} | ||
} | ||
|
||
sourceSets { | ||
main { | ||
java { | ||
srcDir 'src/main/java' | ||
} | ||
} | ||
|
||
test { | ||
java { | ||
srcDir 'src/test/java' | ||
} | ||
} | ||
} | ||
|
||
jar { | ||
from sourceSets.main.output | ||
from sourceSets.test.output | ||
manifest { | ||
attributes('Implementation-jaeger-java-crossdock': 'jaeger-java-crossdock', 'Implementation-Version': project.version) | ||
attributes 'Main-Class': 'com.uber.jaeger.crossdock.JerseyServer' | ||
} | ||
} |
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,52 @@ | ||
version: '2' | ||
|
||
services: | ||
crossdock: | ||
image: crossdock/crossdock | ||
links: | ||
- go | ||
- java | ||
environment: | ||
- WAIT_FOR=go,java | ||
|
||
- AXIS_CLIENT=go | ||
- AXIS_S1NAME=go,java | ||
- AXIS_SAMPLED=true,false | ||
- AXIS_S2NAME=go,java | ||
- AXIS_S2TRANSPORT=http,tchannel | ||
- AXIS_S3NAME=go,java | ||
- AXIS_S3TRANSPORT=http,tchannel | ||
|
||
- BEHAVIOR_TRACE=client,s1name,sampled,s2name,s2transport,s3name,s3transport | ||
|
||
- REPORT=compact | ||
go: | ||
image: jaegertracing/xdock-go | ||
ports: | ||
- "8080-8082" | ||
|
||
java: | ||
build: . | ||
ports: | ||
- "8080-8082" | ||
# node: | ||
# image: yarpc/yarpc-node | ||
# ports: | ||
# - "8080-8082" | ||
# | ||
# java: | ||
# image: yarpc/yarpc-java | ||
# ports: | ||
# - "8080-8082" | ||
# | ||
# python: | ||
# image: yarpc/yarpc-python | ||
# ports: | ||
# - "8080:8082" | ||
# | ||
# python-sync: | ||
# image: yarpc/yarpc-python | ||
# ports: | ||
# - 8080 | ||
# environment: | ||
# - SYNC=1 |
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,21 @@ | ||
PROJCT=jaeger-java-crossdock | ||
XDOCK_YAML=$(PROJCT)/docker-compose.yml | ||
|
||
.PHONY: crossdock | ||
crossdock: gradle-compile | ||
docker-compose -f $(XDOCK_YAML) kill java | ||
docker-compose -f $(XDOCK_YAML) rm -f java | ||
docker-compose -f $(XDOCK_YAML) build java | ||
docker-compose -f $(XDOCK_YAML) run crossdock 2>&1 | tee run-crossdock.log | ||
grep 'Tests passed!' run-crossdock.log | ||
|
||
.PHONY: crossdock-fresh | ||
crossdock-fresh: gradle-compile | ||
docker-compose -f $(XDOCK_YAML) kill | ||
docker-compose -f $(XDOCK_YAML) rm --force | ||
docker-compose -f $(XDOCK_YAML) pull | ||
docker-compose -f $(XDOCK_YAML) build | ||
docker-compose -f $(XDOCK_YAML) run crossdock | ||
|
||
gradle-compile: | ||
./gradlew clean :jaeger-java-crossdock:shadowJar |
28 changes: 28 additions & 0 deletions
28
jaeger-java-crossdock/src/main/java/com/uber/jaeger/crossdock/Constants.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,28 @@ | ||
/* | ||
* Copyright (c) 2016, Uber Technologies, Inc | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package com.uber.jaeger.crossdock; | ||
|
||
public class Constants { | ||
public final static String BAGGAGE_KEY = "crossdock-baggage-key"; | ||
public final static String TRANSPORT_HTTP = "HTTP"; | ||
public final static String TRANSPORT_TCHANNEL = "TCHANNEL"; | ||
} |
110 changes: 110 additions & 0 deletions
110
jaeger-java-crossdock/src/main/java/com/uber/jaeger/crossdock/JerseyServer.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,110 @@ | ||
/* | ||
* Copyright (c) 2016, Uber Technologies, Inc | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package com.uber.jaeger.crossdock; | ||
|
||
import java.net.URI; | ||
|
||
import javax.ws.rs.client.Client; | ||
import javax.ws.rs.client.ClientBuilder; | ||
|
||
import com.uber.jaeger.context.TraceContext; | ||
import com.uber.jaeger.crossdock.resources.behavior.ExceptionMapper; | ||
import com.uber.jaeger.crossdock.resources.behavior.http.TraceBehaviorResource; | ||
import com.uber.jaeger.crossdock.resources.behavior.tchannel.TChannelServer; | ||
import com.uber.jaeger.crossdock.resources.health.HealthResource; | ||
import com.uber.jaeger.Configuration.ReporterConfiguration; | ||
import com.uber.jaeger.Configuration.SamplerConfiguration; | ||
import com.uber.jaeger.filters.jaxrs2.Configuration; | ||
import com.uber.jaeger.filters.jaxrs2.TracingUtils; | ||
import org.glassfish.grizzly.http.server.HttpServer; | ||
import org.glassfish.hk2.utilities.binding.AbstractBinder; | ||
import org.glassfish.jersey.filter.LoggingFilter; | ||
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; | ||
import org.glassfish.jersey.jackson.JacksonFeature; | ||
import org.glassfish.jersey.server.ResourceConfig; | ||
|
||
public class JerseyServer { | ||
private final HttpServer server; | ||
public static Client client; | ||
public final static String SERVICE_NAME = "java"; | ||
|
||
|
||
public JerseyServer(String hostPort, Class... resourceClasses) { | ||
final String samplingType = SamplerConfiguration.CONST; | ||
final Number samplingParam = 0; | ||
final boolean disable = false; | ||
final boolean logging = true; | ||
|
||
final Configuration config = new Configuration(SERVICE_NAME, disable, | ||
new SamplerConfiguration(samplingType, samplingParam), | ||
new ReporterConfiguration(logging, null, null, null, null)); | ||
|
||
// create a resource config that scans for JAX-RS resources and providers | ||
final ResourceConfig rc = new ResourceConfig(); | ||
|
||
for (Class clz : resourceClasses) { | ||
rc.packages(clz.getPackage().getName()); | ||
} | ||
|
||
rc.register(TracingUtils.serverFilter(config)) | ||
.register(LoggingFilter.class) | ||
.register(ExceptionMapper.class) | ||
.register(JacksonFeature.class) | ||
.register( | ||
new AbstractBinder() { | ||
@Override | ||
protected void configure() { | ||
bind(config).to(Configuration.class); | ||
} | ||
}); | ||
|
||
// create and start a new instance of grizzly http server | ||
// exposing the Jersey application at BASE_URI | ||
String baseURI = String.format("http://%s/", hostPort); | ||
server = GrizzlyHttpServerFactory.createHttpServer(URI.create(baseURI), rc); | ||
client = initializeClient(config); | ||
} | ||
|
||
private static Client initializeClient(final Configuration config) { | ||
return ClientBuilder.newClient() | ||
.register(ExceptionMapper.class) | ||
.register(TracingUtils.clientFilter(config)) | ||
.register( | ||
new AbstractBinder() { | ||
@Override | ||
protected void configure() { | ||
bind(TracingUtils.getTraceContext()).to(TraceContext.class); | ||
} | ||
}) | ||
.register(JacksonFeature.class); | ||
} | ||
|
||
public void shutdown() { | ||
server.shutdown(); | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
new JerseyServer("0.0.0.0:8081", TraceBehaviorResource.class); | ||
new TChannelServer(8082).start(); | ||
new JerseyServer("0.0.0.0:8080", HealthResource.class); | ||
} | ||
} |
Oops, something went wrong.