-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working XRayUDPReporter and STORAGE_TYPE xray
This adds `XRayUDPReporter` which defaults to localhost:2000 or AWS_XRAY_DAEMON_ADDRESS. This can be used in applications directly or integrated with a zipkin-server where `STORAGE_TYPE=xray` Note: this is experimental and makes assumptions about trace ID format: See openzipkin/b3-propagation#6
- Loading branch information
Adrian Cole
committed
Oct 17, 2017
1 parent
80c6bc9
commit 3e1b56d
Showing
28 changed files
with
914 additions
and
14 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
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
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,49 @@ | ||
# autoconfigure-storage-xray | ||
|
||
## Overview | ||
|
||
This is a Spring Boot [AutoConfiguration](http://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-auto-configuration.html) | ||
module that can be added to a [Zipkin Server](https://github.com/openzipkin/zipkin/tree/master/zipkin-server) | ||
deployment to send Spans to Amazon XRay. | ||
|
||
This currently only supports sending to an XRay UDP daemon, not reading back spans from the service. | ||
Internally this module wraps the [XRayUDPStorage](https://github.com/openzipkin/zipkin-aws/tree/master/storage-xray-udp) | ||
and exposes configuration options through environment variables. | ||
|
||
## Experimental | ||
* Note: This is currently experimental! * | ||
* Note: This requires reporters send 128-bit trace IDs, with the first 32bits as epoch seconds * | ||
* Check https://github.com/openzipkin/b3-propagation/issues/6 for tracers that support epoch128 trace IDs | ||
|
||
## Usage | ||
|
||
Download the module from [TODO] link and extract it to a directory relative to the | ||
Zipkin Server jar. | ||
|
||
### Configuration | ||
|
||
Configuration can be applied either through environment variables or an external Zipkin | ||
configuration file. The module includes default configuration that can be used as a | ||
[reference](https://github.com/openzipkin/zipkin-aws/tree/master/autoconfigure/storage-xray/src/main/resources/zipkin-server-xray.yml) | ||
for users that prefer a file based approach. | ||
|
||
##### Environment Variables | ||
|
||
- `AWS_XRAY_DAEMON_ADDRESS` The UDP endpoint to send spans to. _Defaults to localhost:2000_ | ||
|
||
### Running | ||
|
||
```bash | ||
STORAGE_TYPE=xray | ||
java -Dloader.path=xray -Dspring.profiles.active=xray -cp zipkin.jar org.springframework.boot.loader.PropertiesLauncher | ||
``` | ||
|
||
### Testing | ||
|
||
Once your storage is enabled, verify it is running: | ||
```bash | ||
$ curl -s localhost:9411/health|jq .zipkin.XrayStorage | ||
{ | ||
"status": "UP" | ||
} | ||
``` |
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,71 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2016-2017 The OpenZipkin Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
in compliance with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under the License | ||
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
or implied. See the License for the specific language governing permissions and limitations under | ||
the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>zipkin-autoconfigure</artifactId> | ||
<groupId>io.zipkin.aws</groupId> | ||
<version>0.8.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>zipkin-autoconfigure-storage-xray</artifactId> | ||
<name>Auto Configuration: XRay Storage</name> | ||
|
||
<properties> | ||
<main.basedir>${project.basedir}/../..</main.basedir> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>zipkin-storage-xray-udp</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.zipkin.java</groupId> | ||
<artifactId>zipkin</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<version>${spring-boot.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>repackage</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<layout>MODULE</layout> | ||
<classifier>module</classifier> | ||
<!-- https://github.com/spring-projects/spring-boot/issues/3426 transitive exclude doesn't work --> | ||
<excludeGroupIds> | ||
io.zipkin.java,io.zipkin.zipkin2,org.springframework.boot,org.springframework,commons-codec,com.fasterxml.jackson.core,com.fasterxml.jackson.dataformat,org.apache.httpcomponents,commons-logging,joda-time,software.amazon.ion | ||
</excludeGroupIds> | ||
<!-- already packaged in zipkin-server --> | ||
<excludeArtifactIds>aws-java-sdk-core,aws-java-sdk-sts,jmespath-java</excludeArtifactIds> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
44 changes: 44 additions & 0 deletions
44
...y/src/main/java/zipkin/autoconfigure/storage/xray/ZipkinXRayStorageAutoConfiguration.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,44 @@ | ||
/** | ||
* Copyright 2016-2017 The OpenZipkin Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package zipkin.autoconfigure.storage.xray; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import zipkin.internal.V2StorageComponent; | ||
import zipkin.storage.StorageComponent; | ||
import zipkin2.storage.xray_udp.XRayUDPStorage; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties(zipkin.autoconfigure.storage.xray.ZipkinXRayStorageProperties.class) | ||
@ConditionalOnProperty(name = "zipkin.storage.type", havingValue = "xray") | ||
@ConditionalOnMissingBean(StorageComponent.class) | ||
public class ZipkinXRayStorageAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
V2StorageComponent storage( | ||
zipkin.autoconfigure.storage.xray.ZipkinXRayStorageProperties properties, | ||
@Value("${zipkin.storage.strict-trace-id:true}") boolean strictTraceId) { | ||
XRayUDPStorage result = properties.toBuilder().strictTraceId(strictTraceId).build(); | ||
return V2StorageComponent.create(result); | ||
} | ||
|
||
@Bean XRayUDPStorage v2Storage(V2StorageComponent component) { | ||
return (XRayUDPStorage) component.delegate(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...age-xray/src/main/java/zipkin/autoconfigure/storage/xray/ZipkinXRayStorageProperties.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 @@ | ||
/** | ||
* Copyright 2016-2017 The OpenZipkin Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package zipkin.autoconfigure.storage.xray; | ||
|
||
import java.io.Serializable; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import zipkin2.storage.xray_udp.XRayUDPStorage; | ||
|
||
@ConfigurationProperties("zipkin.storage.xray") | ||
public class ZipkinXRayStorageProperties implements Serializable { // for Spark jobs | ||
private static final long serialVersionUID = 0L; | ||
|
||
/** Amazon X-Ray Daemon UDP daemon address; defaults to localhost:2000 */ | ||
private String daemonAddress; | ||
|
||
public String getDaemonAddress() { | ||
return daemonAddress; | ||
} | ||
|
||
public void setDaemonAddress(String daemonAddress) { | ||
this.daemonAddress = "".equals(daemonAddress) ? null : daemonAddress; | ||
} | ||
|
||
public XRayUDPStorage.Builder toBuilder() { | ||
XRayUDPStorage.Builder builder = XRayUDPStorage.newBuilder(); | ||
if (daemonAddress != null) builder.address(daemonAddress); | ||
return builder; | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
autoconfigure/storage-xray/src/main/resources/META-INF/spring.factories
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 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||
zipkin.autoconfigure.storage.xray.ZipkinXRayStorageAutoConfiguration |
6 changes: 6 additions & 0 deletions
6
autoconfigure/storage-xray/src/main/resources/zipkin-server-xray.yml
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 @@ | ||
# When enabled, this allows shorter env properties (ex -Dspring.profiles.active=xray) | ||
zipkin: | ||
storage: | ||
xray: | ||
# Amazon X-Ray Daemon UDP daemon address; defaults to localhost:2000 | ||
daemon-address: ${AWS_XRAY_DAEMON_ADDRESS:} |
76 changes: 76 additions & 0 deletions
76
...orage-xray/src/test/java/zipkin2/storage/xray/ZipkinXRayStorageAutoConfigurationTest.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,76 @@ | ||
/** | ||
* Copyright 2016-2017 The OpenZipkin Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package zipkin2.storage.xray; | ||
|
||
import org.junit.After; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
import org.springframework.beans.factory.NoSuchBeanDefinitionException; | ||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; | ||
import org.springframework.context.annotation.AnnotationConfigApplicationContext; | ||
import zipkin.autoconfigure.storage.xray.ZipkinXRayStorageAutoConfiguration; | ||
import zipkin.autoconfigure.storage.xray.ZipkinXRayStorageProperties; | ||
import zipkin2.storage.xray_udp.XRayUDPStorage; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.springframework.boot.test.util.EnvironmentTestUtils.addEnvironment; | ||
|
||
public class ZipkinXRayStorageAutoConfigurationTest { | ||
|
||
@Rule public ExpectedException thrown = ExpectedException.none(); | ||
|
||
AnnotationConfigApplicationContext context; | ||
|
||
@After public void close() { | ||
if (context != null) { | ||
context.close(); | ||
} | ||
} | ||
|
||
@Test public void doesntProvideStorageComponent_whenStorageTypeNotXRay() { | ||
context = new AnnotationConfigApplicationContext(); | ||
addEnvironment(context, "zipkin.storage.type:elasticsearch"); | ||
context.register(PropertyPlaceholderAutoConfiguration.class, | ||
ZipkinXRayStorageAutoConfiguration.class); | ||
context.refresh(); | ||
|
||
thrown.expect(NoSuchBeanDefinitionException.class); | ||
context.getBean(XRayUDPStorage.class); | ||
} | ||
|
||
@Test public void providesStorageComponent_whenStorageTypeXRay() { | ||
context = new AnnotationConfigApplicationContext(); | ||
addEnvironment(context, "zipkin.storage.type:xray"); | ||
context.register(PropertyPlaceholderAutoConfiguration.class, | ||
ZipkinXRayStorageAutoConfiguration.class); | ||
context.refresh(); | ||
|
||
assertThat(context.getBean(XRayUDPStorage.class)).isNotNull(); | ||
} | ||
|
||
@Test public void canOverrideProperty_daemonAddress() { | ||
context = new AnnotationConfigApplicationContext(); | ||
addEnvironment(context, | ||
"zipkin.storage.type:xray", | ||
"zipkin.storage.xray.daemon-address:localhost:3000" | ||
); | ||
context.register(PropertyPlaceholderAutoConfiguration.class, | ||
ZipkinXRayStorageAutoConfiguration.class); | ||
context.refresh(); | ||
|
||
assertThat(context.getBean(ZipkinXRayStorageProperties.class).getDaemonAddress()) | ||
.isEqualTo("localhost:3000"); | ||
} | ||
} |
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
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
Oops, something went wrong.