Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Commit 1556287

Browse files
committed
Merge branch 'release/0.9.5'
2 parents b756cd1 + cd1b9d5 commit 1556287

File tree

11 files changed

+270
-42
lines changed

11 files changed

+270
-42
lines changed

.travis.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,3 @@ cache:
1111
- "$HOME/.gradle/caches/"
1212
- "$HOME/.gradle/wrapper/"
1313
- "$HOME/.m2"
14-
env:
15-
global:
16-
- secure: crwXv5Q/iCtIIC81QWgWYNfuGJxSQQjVn83vvRoRMXmfSZ02NnQfDos+p1GxxbIXLUQ8NsaLc8cg0o2PQgsK/l0d7nDExix5Rt+AwzU4UOrUcZh46MgEeZDow4q6ySToOHaeKsaRnbTIpAwU28o9fnZ9ViaQ7s2uZWQZXYigGf0PN1ca9E8MJ6VEMvp34e2wJok6woaWG9ALCL2b5viofTv0zdHXWfGV4rdz9Rq0fThmFn4BlmHdcTwGt2ZLdWcEbzv0qNYNAiVvNJd4uWHOnjRceslAZ/JZxgIzSHK0ctNiZdc9rRNo8BHGQqKvmZqmbzUAU07uS0+iLBnm89KKJyQCXKulDv7NM0ShiFexMQ17TUOdlJtH65ypzUIJ+sbSOj2M+NhThUD8OQlebvjKF6t8M9f1NIXkkH/Xw2XJ146ANBcGyjALVFDIqlKIyCtIoY3/teQWccfbAzBglC24QBizpfgmdBEGOJXs2qR0NxzcIRNc1o9XPyT9BJxa+9JnHyHbF+LG07j1LfaaJSQBIYL7xjDBwEEIOEmP3UrISwjvs1fOQA3oYINguXtl7qi3wNylv35e5xw5acijcTTYHRSY6A5rPdokbK0fCQHCrHldBYDc8Bvy+GnjnYQHynjdWGbTnkvMgvYe2aHD+mH5pO5V7DRYHhnJsuMuscRIELc=
17-
- secure: ZMu9rhzTT1F6pyqqrd0TGhAeUGigAvGZT5rJv2ifZJEB8+FOQ+/ylJ/Q3Gq9Wx8quWVR/ocTWF8yEuA1BlZF1Z+tfOcC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3rGPYHniFS9lQJZaJSJUU8hlApqsTQfK+5j8vIKmPe0ur39XriVeC8Kam8SWMymjLrLaNGOe0XvST9MLKKel7Aj9mknNyZ0dQEr24BLlN/vGHQsHTrpnReLHP3szuF5FXZQsqYQ2uN4Q5000O6IJfbD9FcBJHzOCtyIlNkJ12qK6GiLChwqcpv9muQZcaH8=
19-
- secure: fyh1tUQJBijuGd5jO6ZHl2yn8u5uKgz+9tKgrGNBg2NNlxXvq1TJqBj1/fkZonH3rxPAH4AnmxsR4ktWKhmTci16D3ATflpxVOSQYHdMqbsxpNt4e+um/lnFLp6WORLkcnFAsA0rUrH3eRJXPfZ6YgcY3L4tddiT0sqLZ1ECo5gA915CPN8ANioHzooWJgVBcbr34z2HcJudgKws4C+MoiTKv3C9Ijamg+30D/wgiyRJXPD/azb2KoVx+Bk5yIQuBOl3G/a/LMpK+kv/2jZQjUT/gnKLEvRu9H5xJIL41mFTRgmZxD9E0Rb0VeAaYICfo+4K2g2smXeA/Eb9lmwMQYiEKdG2IH2chjPggBM0hsB42pGc+mFDKaNCtQSVkbQkrg2CmDMwvBaL7IBFNUmlSbZfG1PeQluSNs9uECR0MFM/zyNECLGkcrf3kZXHMuQ+1jYPWf37CuiNbEnN8sQm65t9wqX3TqRB8rksGaThVvYizIon7zuuIrKINynGDEc3ygVUOeOBLT+U9AaF1jatkxuwiZ/VJaReYuJvH76wCUb6k91RQA9udK4n8h8aMomOmTyIWRSnEFObDs1RW6Lixh5PRShTKG8ffoY0vM5IO5i17dPFOmIRo99yqKiWPcfQLK8IP0SiCwc6w0pqAns6H/r8qBgk6BoXGnBT5kyzKr8=

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
group=io.netifi.proteus
2-
version=0.9.4
2+
version=0.9.5

gradle/java.gradle

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ task ciVersion {
3535
build.dependsOn ciVersion
3636

3737
ext {
38-
rsocketRpcVersion = '0.2.2'
38+
rsocketRpcVersion = '0.2.4'
3939
protobufVersion = '3.6.1'
4040
}
4141

4242
repositories {
4343
jcenter()
44-
mavenLocal()
4544
maven {
46-
url = 'https://dl.bintray.com/netifi/netifi-oss'
45+
url = 'https://dl.bintray.com/rsocket-admin/RSocket'
4746
}
4847
}
4948

@@ -88,14 +87,14 @@ dependencies {
8887
testCompile 'junit:junit:4.12'
8988

9089
testCompile 'javax.inject:javax.inject:1'
91-
testCompile 'io.projectreactor:reactor-test:3.1.9.RELEASE'
90+
testCompile 'io.projectreactor:reactor-test:3.2.1.RELEASE'
9291
testCompile "com.google.protobuf:protobuf-java:$protobufVersion"
9392
testCompile 'org.hdrhistogram:HdrHistogram:2.1.10'
9493
testCompile 'org.apache.logging.log4j:log4j-api:2.9.0'
9594
testCompile 'org.apache.logging.log4j:log4j-core:2.9.0'
9695
testCompile 'org.apache.logging.log4j:log4j-slf4j-impl:2.9.0'
97-
testCompile 'io.rsocket:rsocket-transport-netty:0.11.7'
98-
testCompile 'io.rsocket:rsocket-transport-local:0.11.7'
96+
testCompile 'io.rsocket:rsocket-transport-netty:0.11.9'
97+
testCompile 'io.rsocket:rsocket-transport-local:0.11.9'
9998
testCompile 'org.mockito:mockito-all:1.10.19'
10099
}
101100

proteus-client/src/main/java/io/netifi/proteus/Proteus.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import reactor.core.Exceptions;
2727
import reactor.core.publisher.Mono;
2828
import reactor.core.publisher.MonoProcessor;
29-
import reactor.ipc.netty.tcp.TcpClient;
29+
import reactor.netty.tcp.TcpClient;
3030

3131
/** This is where the magic happens */
3232
public class Proteus implements Closeable {
@@ -256,7 +256,7 @@ public Proteus build() {
256256
if (sslDisabled) {
257257
clientTransportFactory =
258258
address -> {
259-
TcpClient client = TcpClient.create(opts -> opts.connectAddress(() -> address));
259+
TcpClient client = TcpClient.create().addressSupplier(() -> address);
260260
return TcpClientTransport.create(client);
261261
};
262262
} else {
@@ -277,8 +277,7 @@ public Proteus build() {
277277
clientTransportFactory =
278278
address -> {
279279
TcpClient client =
280-
TcpClient.create(
281-
opts -> opts.connectAddress(() -> address).sslContext(sslContext));
280+
TcpClient.create().addressSupplier(() -> address).secure(sslContext);
282281
return TcpClientTransport.create(client);
283282
};
284283
} catch (Exception sslException) {

proteus-frames/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dependencies {
2-
compile 'io.rsocket:rsocket-core:0.11.7'
2+
compile 'io.rsocket:rsocket-core:0.11.9'
33
}

proteus-metrics-prometheus/src/main/java/io/netifi/proteus/prometheus/ProteusPrometheusBridge.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
import reactor.core.publisher.DirectProcessor;
2727
import reactor.core.publisher.Flux;
2828
import reactor.core.publisher.Mono;
29-
import reactor.ipc.netty.http.server.HttpServer;
30-
import reactor.ipc.netty.http.server.HttpServerRequest;
31-
import reactor.ipc.netty.http.server.HttpServerResponse;
29+
import reactor.netty.http.server.HttpServer;
30+
import reactor.netty.http.server.HttpServerRequest;
31+
import reactor.netty.http.server.HttpServerResponse;
3232

3333
@Named("ProteusPrometheusBridge")
3434
public class ProteusPrometheusBridge implements MetricsSnapshotHandler {
@@ -99,8 +99,11 @@ public static void main(String... args) {
9999
}
100100

101101
private void init() {
102-
HttpServer.create(bindAddress, bindPort)
103-
.newRouter(routes -> routes.post(metricsUrl, this::handle).get(metricsUrl, this::handle))
102+
HttpServer.create()
103+
.host(bindAddress)
104+
.port(bindPort)
105+
.route(routes -> routes.post(metricsUrl, this::handle).get(metricsUrl, this::handle))
106+
.bind()
104107
.subscribe();
105108
}
106109

proteus-tracing-openzipkin/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies {
1010
protobuf project (':proteus-tracing-idl')
1111
compile project (':proteus-client')
1212

13-
compile 'io.projectreactor.addons:reactor-adapter:3.1.7.RELEASE'
13+
compile 'io.projectreactor.addons:reactor-adapter:3.2.0.RELEASE'
1414
compile "com.google.protobuf:protobuf-java-util:$protobufVersion"
1515

1616
compile 'io.opentracing:opentracing-api:0.31.0'
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package io.netifi.proteus.tracing;
2+
3+
import brave.Tracing;
4+
import brave.opentracing.BraveTracer;
5+
import io.netifi.proteus.Proteus;
6+
import io.netifi.proteus.rsocket.ProteusSocket;
7+
import io.opentracing.Tracer;
8+
import java.util.Optional;
9+
import java.util.function.Supplier;
10+
import javax.inject.Inject;
11+
import javax.inject.Named;
12+
13+
@Named("ProteusTracerSupplier")
14+
public class ProteusTracerSupplier implements Supplier<Tracer> {
15+
private final Tracer tracer;
16+
17+
@Inject
18+
public ProteusTracerSupplier(Proteus proteus, Optional<String> tracingGroup) {
19+
ProteusSocket proteusSocket = proteus.group(tracingGroup.orElse("com.netifi.proteus.tracing"));
20+
21+
ProteusTracingServiceClient client = new ProteusTracingServiceClient(proteusSocket);
22+
ProteusReporter reporter =
23+
new ProteusReporter(client, proteus.getGroupName(), proteus.getDestination());
24+
25+
Tracing tracing = Tracing.newBuilder().spanReporter(reporter).build();
26+
27+
tracer = BraveTracer.create(tracing);
28+
}
29+
30+
@Override
31+
public Tracer get() {
32+
return tracer;
33+
}
34+
}

proteus-tracing-openzipkin/src/main/java/io/netifi/proteus/tracing/ProteusZipkinHttpBridge.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
import reactor.core.Exceptions;
1414
import reactor.core.publisher.Flux;
1515
import reactor.core.publisher.Mono;
16-
import reactor.ipc.netty.http.client.HttpClient;
17-
import reactor.ipc.netty.resources.PoolResources;
16+
import reactor.netty.ByteBufFlux;
17+
import reactor.netty.http.client.HttpClient;
18+
import reactor.netty.resources.ConnectionProvider;
1819
import zipkin2.proto3.Span;
1920

2021
public class ProteusZipkinHttpBridge implements ProteusTracingService {
@@ -82,17 +83,15 @@ public static void main(String... args) {
8283
private synchronized HttpClient getClient() {
8384
if (httpClient == null) {
8485
this.httpClient =
85-
HttpClient.builder()
86-
.options(
87-
builder ->
88-
builder
89-
.compression(true)
90-
.poolResources(PoolResources.fixed("proteusZipkinBridge"))
91-
.option(ChannelOption.SO_KEEPALIVE, true)
92-
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 30_000)
86+
HttpClient.create(ConnectionProvider.fixed("proteusZipkinBridge"))
87+
.compress(true)
88+
.port(port)
89+
.tcpConfiguration(
90+
tcpClient ->
91+
tcpClient
9392
.host(host)
94-
.port(port))
95-
.build();
93+
.option(ChannelOption.SO_KEEPALIVE, true)
94+
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 30_000));
9695
}
9796
return httpClient;
9897
}
@@ -127,12 +126,11 @@ public Mono<Ack> streamSpans(Publisher<Span> messages, ByteBuf metadata) {
127126
.concatMap(
128127
spans ->
129128
getClient()
130-
.post(
131-
zipkinSpansUrl,
132-
request -> {
133-
request.addHeader("Content-Type", "application/json");
134-
return request.sendString(Mono.just(spans));
135-
})
129+
.headers(hh -> hh.add("Content-Type", "application/json"))
130+
.post()
131+
.uri(zipkinSpansUrl)
132+
.send(ByteBufFlux.fromString(Mono.just(spans)))
133+
.response()
136134
.timeout(Duration.ofSeconds(30))
137135
.doOnError(throwable -> resetHttpClient()),
138136
8)
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
package io.netifi.proteus.tracing;
2+
3+
import com.fasterxml.jackson.core.JsonParser;
4+
import com.fasterxml.jackson.core.JsonToken;
5+
import com.fasterxml.jackson.core.type.TypeReference;
6+
import com.fasterxml.jackson.databind.DeserializationContext;
7+
import com.fasterxml.jackson.databind.ObjectMapper;
8+
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
9+
import com.fasterxml.jackson.databind.module.SimpleDeserializers;
10+
import com.hubspot.jackson.datatype.protobuf.ProtobufModule;
11+
import io.netty.handler.codec.json.JsonObjectDecoder;
12+
import java.io.IOException;
13+
import java.io.InputStream;
14+
import java.util.concurrent.TimeUnit;
15+
import java.util.function.Function;
16+
import org.reactivestreams.Publisher;
17+
import reactor.core.Exceptions;
18+
import reactor.core.publisher.Flux;
19+
import reactor.core.publisher.Mono;
20+
import reactor.netty.http.client.HttpClient;
21+
import zipkin2.proto3.Span;
22+
23+
public class TracesStreamer {
24+
25+
private final ObjectMapper objectMapper = protoMapper();
26+
private Function<Integer, Publisher<InputStream>> inputSource;
27+
28+
public TracesStreamer(String zipkinUrl, Mono<HttpClient> client) {
29+
this(zipkinServerStream(zipkinUrl, client));
30+
}
31+
32+
public TracesStreamer(Publisher<InputStream> tracesSource) {
33+
this(v -> tracesSource);
34+
}
35+
36+
private TracesStreamer(Function<Integer, Publisher<InputStream>> inputSource) {
37+
this.inputSource = inputSource;
38+
}
39+
40+
public Flux<Trace> streamTraces(int lookbackSeconds) {
41+
return streamTraces(inputSource.apply(lookbackSeconds));
42+
}
43+
44+
Flux<Trace> streamTraces(Publisher<InputStream> input) {
45+
return Flux.from(input)
46+
.filter(
47+
is -> {
48+
try {
49+
return is.available() > 0;
50+
} catch (IOException e) {
51+
throw Exceptions.propagate(e);
52+
}
53+
})
54+
.map(
55+
is -> {
56+
try {
57+
return objectMapper.readValue(is, new TypeReference<Trace>() {});
58+
} catch (IOException e) {
59+
throw Exceptions.propagate(e);
60+
}
61+
});
62+
}
63+
64+
private static Function<Integer, Publisher<InputStream>> zipkinServerStream(
65+
String zipkinUrl, Mono<HttpClient> client) {
66+
return lookbackSeconds ->
67+
client.flatMapMany(
68+
c ->
69+
c.doOnRequest(
70+
(__, connection) -> connection.addHandler(new JsonObjectDecoder(true)))
71+
.get()
72+
.uri(zipkinQuery(zipkinUrl, lookbackSeconds))
73+
.responseContent()
74+
.asInputStream());
75+
}
76+
77+
private static String zipkinQuery(String zipkinUrl, int lookbackSeconds) {
78+
long lookbackMillis = TimeUnit.SECONDS.toMillis(lookbackSeconds);
79+
return zipkinUrl + "?lookback=" + lookbackMillis + "&limit=100000";
80+
}
81+
82+
private ObjectMapper protoMapper() {
83+
ObjectMapper mapper = new ObjectMapper();
84+
ProtobufModule module = new CustomProtoModule();
85+
mapper.registerModule(module);
86+
return mapper;
87+
}
88+
89+
public static class CustomProtoModule extends ProtobufModule {
90+
@Override
91+
public void setupModule(SetupContext context) {
92+
super.setupModule(context);
93+
SimpleDeserializers deser = new SimpleDeserializers();
94+
deser.addDeserializer(Trace.class, new TracersDeserializer());
95+
context.addDeserializers(deser);
96+
}
97+
}
98+
99+
public static class TracersDeserializer extends StdDeserializer<Trace> {
100+
101+
public TracersDeserializer() {
102+
this(null);
103+
}
104+
105+
protected TracersDeserializer(Class<?> vc) {
106+
super(vc);
107+
}
108+
109+
@Override
110+
public Trace deserialize(JsonParser p, DeserializationContext ctx) throws IOException {
111+
Trace.Builder traceBuilder = Trace.newBuilder();
112+
while (p.nextToken() != JsonToken.END_ARRAY) {
113+
traceBuilder.addSpans(ctx.readValue(p, Span.class));
114+
}
115+
return traceBuilder.build();
116+
}
117+
}
118+
}

0 commit comments

Comments
 (0)