diff --git a/benchmarks/pom.xml b/benchmarks/pom.xml index b7965af9215..e0add430148 100644 --- a/benchmarks/pom.xml +++ b/benchmarks/pom.xml @@ -20,7 +20,7 @@ io.zipkin zipkin-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT benchmarks diff --git a/pom.xml b/pom.xml index 3560f8dbc99..5c3c40ad5a5 100755 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ io.zipkin zipkin-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT pom diff --git a/zipkin-collector/activemq/pom.xml b/zipkin-collector/activemq/pom.xml index 87223e23fa3..89e38104b40 100644 --- a/zipkin-collector/activemq/pom.xml +++ b/zipkin-collector/activemq/pom.xml @@ -20,7 +20,7 @@ io.zipkin.zipkin2 zipkin-collector-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT zipkin-collector-activemq diff --git a/zipkin-collector/core/pom.xml b/zipkin-collector/core/pom.xml index 6985e9bb89a..db41b211f70 100644 --- a/zipkin-collector/core/pom.xml +++ b/zipkin-collector/core/pom.xml @@ -20,7 +20,7 @@ io.zipkin.zipkin2 zipkin-collector-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT zipkin-collector diff --git a/zipkin-collector/kafka/pom.xml b/zipkin-collector/kafka/pom.xml index ae9128d8154..d1bd184dd00 100644 --- a/zipkin-collector/kafka/pom.xml +++ b/zipkin-collector/kafka/pom.xml @@ -20,7 +20,7 @@ io.zipkin.zipkin2 zipkin-collector-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT zipkin-collector-kafka diff --git a/zipkin-collector/pom.xml b/zipkin-collector/pom.xml index 709c4eccddc..317785acbd1 100644 --- a/zipkin-collector/pom.xml +++ b/zipkin-collector/pom.xml @@ -20,7 +20,7 @@ io.zipkin zipkin-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT io.zipkin.zipkin2 diff --git a/zipkin-collector/rabbitmq/pom.xml b/zipkin-collector/rabbitmq/pom.xml index 515f7e6addc..3704320c101 100644 --- a/zipkin-collector/rabbitmq/pom.xml +++ b/zipkin-collector/rabbitmq/pom.xml @@ -20,7 +20,7 @@ io.zipkin.zipkin2 zipkin-collector-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT zipkin-collector-rabbitmq diff --git a/zipkin-collector/scribe/pom.xml b/zipkin-collector/scribe/pom.xml index cf2b439514a..d52ecd6e473 100644 --- a/zipkin-collector/scribe/pom.xml +++ b/zipkin-collector/scribe/pom.xml @@ -20,7 +20,7 @@ io.zipkin.zipkin2 zipkin-collector-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT zipkin-collector-scribe diff --git a/zipkin-junit5/pom.xml b/zipkin-junit5/pom.xml index 41348cb0c1a..a97caf9ca49 100644 --- a/zipkin-junit5/pom.xml +++ b/zipkin-junit5/pom.xml @@ -20,7 +20,7 @@ io.zipkin zipkin-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT io.zipkin.zipkin2 diff --git a/zipkin-lens/pom.xml b/zipkin-lens/pom.xml index 3ff3f90ce67..612cf07ccbc 100644 --- a/zipkin-lens/pom.xml +++ b/zipkin-lens/pom.xml @@ -20,7 +20,7 @@ io.zipkin zipkin-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT zipkin-lens diff --git a/zipkin-server/README.md b/zipkin-server/README.md index 4cd9a77159f..dec0a93225c 100644 --- a/zipkin-server/README.md +++ b/zipkin-server/README.md @@ -111,7 +111,8 @@ exposition [text format version 0.0.4](https://prometheus.io/docs/instrumenting/ ### Collector -Collector metrics are broken down by transport. The following are exported to the "/metrics" endpoint: +Collector metrics are broken down by transport, where the defaults are "http" and "grpc". The +following are exported to the "/metrics" endpoint: | Metric | Description | |------------------------------------------------------|---------------------------------------------------------------------------------------| @@ -378,7 +379,9 @@ As this feature is experimental, it is not recommended to run this in production ## Collector ### HTTP Collector -The HTTP collector is enabled by default. It accepts spans via `POST /api/v1/spans` and `POST /api/v2/spans`. +The HTTP collector is enabled by default. It accepts spans via `POST /api/v1/spans` and +`POST /api/v2/spans`, on the `${QUERY_PORT}` which defaults to 9411. + The HTTP collector supports the following configuration: | Property | Environment Variable | Description | @@ -494,17 +497,18 @@ Example usage: $ RABBIT_ADDRESSES=localhost java -jar zipkin.jar ``` -### gRPC Collector (Experimental) -You can enable a gRPC span collector endpoint by setting `COLLECTOR_GRPC_ENABLED=true`. The -`zipkin.proto3.SpanService/Report` endpoint will run on the same port as normal HTTP (9411). +### gRPC Collector -Example usage: +The gRPC collector is enabled by default. It accepts spans via `zipkin.proto3.SpanService/Report`, +on the `${QUERY_PORT}` which defaults to 9411. -```bash -$ COLLECTOR_GRPC_ENABLED=true java -jar zipkin.jar -``` +The gRPC collector supports the following configuration: + +| Variable | Description | +|--------------------------|--------------------------------------------------------| +| `COLLECTOR_GRPC_ENABLED` | `false` disables the gRPC service. Defaults to `true`. | -As this service is experimental, it is not recommended to run this in production environments. +The proto definition is here: https://github.com/openzipkin/zipkin-api/blob/master/zipkin.proto ## Service Registration diff --git a/zipkin-server/pom.xml b/zipkin-server/pom.xml index 86e6138e273..14e4b7b9791 100644 --- a/zipkin-server/pom.xml +++ b/zipkin-server/pom.xml @@ -20,7 +20,7 @@ io.zipkin zipkin-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT zipkin-server diff --git a/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinGrpcCollector.java b/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinGrpcCollector.java index 421eff52e38..a36323156f6 100644 --- a/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinGrpcCollector.java +++ b/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinGrpcCollector.java @@ -30,7 +30,7 @@ import zipkin2.storage.StorageComponent; /** Collector for receiving spans on a gRPC endpoint. */ -@ConditionalOnProperty(name = "zipkin.collector.grpc.enabled") // disabled by default +@ConditionalOnProperty(name = "zipkin.collector.grpc.enabled", matchIfMissing = true) final class ZipkinGrpcCollector { @Bean ArmeriaServerConfigurator grpcCollectorConfigurator(StorageComponent storage, @@ -56,7 +56,8 @@ static final class SpanService extends AbstractUnsafeUnaryGrpcService { this.metrics = metrics; } - @Override protected CompletionStage handleMessage(ServiceRequestContext ctx, ByteBuf bytes) { + @Override + protected CompletionStage handleMessage(ServiceRequestContext ctx, ByteBuf bytes) { metrics.incrementMessages(); metrics.incrementBytes(bytes.readableBytes()); diff --git a/zipkin-server/src/main/resources/zipkin-server-shared.yml b/zipkin-server/src/main/resources/zipkin-server-shared.yml index 255b0c8819d..54de6903d71 100644 --- a/zipkin-server/src/main/resources/zipkin-server-shared.yml +++ b/zipkin-server/src/main/resources/zipkin-server-shared.yml @@ -26,11 +26,11 @@ zipkin: # Optional password to connect to the broker password: ${ACTIVEMQ_PASSWORD:} http: - # Set to false to disable creation of spans via HTTP collector API + # Set false to disable creation of spans via HTTP collector API enabled: ${COLLECTOR_HTTP_ENABLED:${HTTP_COLLECTOR_ENABLED:true}} grpc: - # Set to true to enable the GRPC collector - enabled: ${COLLECTOR_GRPC_ENABLED:false} + # Set false to disable the GRPC collector + enabled: ${COLLECTOR_GRPC_ENABLED:true} kafka: enabled: ${COLLECTOR_KAFKA_ENABLED:true} # Kafka bootstrap broker list, comma-separated host:port values. Setting this activates the diff --git a/zipkin-server/src/test/java/zipkin2/server/internal/ITZipkinGrpcCollector.java b/zipkin-server/src/test/java/zipkin2/server/internal/ITZipkinGrpcCollector.java index 34cf413bb65..8847999f830 100644 --- a/zipkin-server/src/test/java/zipkin2/server/internal/ITZipkinGrpcCollector.java +++ b/zipkin-server/src/test/java/zipkin2/server/internal/ITZipkinGrpcCollector.java @@ -32,7 +32,6 @@ import zipkin2.codec.SpanBytesDecoder; import zipkin2.codec.SpanBytesEncoder; import zipkin2.proto3.ListOfSpans; -import zipkin2.proto3.ReportResponse; import zipkin2.storage.InMemoryStorage; import static okhttp3.Protocol.H2_PRIOR_KNOWLEDGE; @@ -48,7 +47,6 @@ "server.port=0", "spring.config.name=zipkin-server", "spring.main.banner-mode=off", - "zipkin.collector.grpc.enabled=true" } ) class ITZipkinGrpcCollector { @@ -61,17 +59,17 @@ class ITZipkinGrpcCollector { OkHttpClient client = new OkHttpClient.Builder().protocols(List.of(H2_PRIOR_KNOWLEDGE)).build(); - ListOfSpans request; + ListOfSpans grpcRequest; @BeforeEach void sanityCheckCodecCompatible() throws IOException { - request = ListOfSpans.ADAPTER.decode(SpanBytesEncoder.PROTO3.encodeList(TestObjects.TRACE)); + grpcRequest = ListOfSpans.ADAPTER.decode(SpanBytesEncoder.PROTO3.encodeList(TestObjects.TRACE)); - assertThat(SpanBytesDecoder.PROTO3.decodeList(request.encode())) + assertThat(SpanBytesDecoder.PROTO3.decodeList(grpcRequest.encode())) .containsExactlyElementsOf(TestObjects.TRACE); // sanity check codec compatible } @Test void report_trace() throws IOException { - callReport(request); // Result is effectively void + callReport(grpcRequest); // Result is effectively void awaitSpans(); @@ -80,30 +78,36 @@ class ITZipkinGrpcCollector { } @Test void report_emptyIsOk() throws IOException { - callReport(new ListOfSpans.Builder().build()); } - ReportResponse callReport(ListOfSpans spans) throws IOException { - Buffer requestBody = new Buffer(); - requestBody.writeByte(0 /* compressedFlag */); - Buffer encodedMessage = new Buffer(); - ListOfSpans.ADAPTER.encode(encodedMessage, spans); - requestBody.writeInt((int) encodedMessage.size()); - requestBody.writeAll(encodedMessage); - - Response response = client.newCall(new Request.Builder() - .url(url(server, "/zipkin.proto3.SpanService/Report")) - .addHeader("te", "trailers") - .post(RequestBody.create(requestBody.snapshot(), MediaType.get("application/grpc"))) - .build()) - .execute(); - - BufferedSource responseBody = response.body().source(); - assertThat((int) responseBody.readByte()).isEqualTo(0); // uncompressed - long encodedLength = responseBody.readInt() & 0xffffffffL; - - return ReportResponse.ADAPTER.decode(responseBody); + void callReport(ListOfSpans spans) throws IOException { + try (Buffer requestBody = new Buffer(); Buffer encodedMessage = new Buffer()) { + requestBody.writeByte(0 /* compressedFlag */); + + ListOfSpans.ADAPTER.encode(encodedMessage, spans); + requestBody.writeInt((int) encodedMessage.size()); + requestBody.writeAll(encodedMessage); + + Request request = new Request.Builder() + .url(url(server, "/zipkin.proto3.SpanService/Report")) + .addHeader("te", "trailers") + .post(RequestBody.create(requestBody.snapshot(), MediaType.get("application/grpc"))) + .build(); + try (Response response = client.newCall(request).execute(); + BufferedSource responseBody = response.body().source()) { + + // We expect this is a valid gRPC over HTTP2 response (Length-Prefixed-Message). + // See https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#responses + byte compressedFlag = responseBody.readByte(); + long messageLength = responseBody.readInt() & 0xffffffffL; + assertThat(responseBody.exhausted()).isTrue(); // We expect a single response + + // Now, verify the Length-Prefixed-Message + assertThat(compressedFlag).isZero(); // server didn't compress + assertThat(messageLength).isZero(); // there are no fields in ReportResponse + } + } } void awaitSpans() { diff --git a/zipkin-server/src/test/java/zipkin2/server/internal/prometheus/ITZipkinMetrics.java b/zipkin-server/src/test/java/zipkin2/server/internal/prometheus/ITZipkinMetrics.java index b56baa34ba0..37b015145b2 100644 --- a/zipkin-server/src/test/java/zipkin2/server/internal/prometheus/ITZipkinMetrics.java +++ b/zipkin-server/src/test/java/zipkin2/server/internal/prometheus/ITZipkinMetrics.java @@ -144,7 +144,14 @@ String scrape() throws Exception { String metrics = getAsString("/metrics"); assertThat(readJson(metrics)).containsOnlyKeys( - "gauge.zipkin_collector.message_spans.http" + "gauge.zipkin_collector.message_spans.grpc" + , "gauge.zipkin_collector.message_bytes.grpc" + , "counter.zipkin_collector.messages.grpc" + , "counter.zipkin_collector.bytes.grpc" + , "counter.zipkin_collector.spans.grpc" + , "counter.zipkin_collector.messages_dropped.grpc" + , "counter.zipkin_collector.spans_dropped.grpc" + , "gauge.zipkin_collector.message_spans.http" , "gauge.zipkin_collector.message_bytes.http" , "counter.zipkin_collector.messages.http" , "counter.zipkin_collector.bytes.http" diff --git a/zipkin-storage/cassandra/pom.xml b/zipkin-storage/cassandra/pom.xml index 34501a30255..afd9187a7b6 100644 --- a/zipkin-storage/cassandra/pom.xml +++ b/zipkin-storage/cassandra/pom.xml @@ -20,7 +20,7 @@ io.zipkin.zipkin2 zipkin-storage-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT zipkin-storage-cassandra diff --git a/zipkin-storage/elasticsearch/pom.xml b/zipkin-storage/elasticsearch/pom.xml index 93540b6cd46..f24470cb4de 100644 --- a/zipkin-storage/elasticsearch/pom.xml +++ b/zipkin-storage/elasticsearch/pom.xml @@ -20,7 +20,7 @@ io.zipkin.zipkin2 zipkin-storage-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT zipkin-storage-elasticsearch diff --git a/zipkin-storage/mysql-v1/pom.xml b/zipkin-storage/mysql-v1/pom.xml index 8493686fcc5..1ed1b2aaa83 100644 --- a/zipkin-storage/mysql-v1/pom.xml +++ b/zipkin-storage/mysql-v1/pom.xml @@ -20,7 +20,7 @@ io.zipkin.zipkin2 zipkin-storage-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT zipkin-storage-mysql-v1 diff --git a/zipkin-storage/pom.xml b/zipkin-storage/pom.xml index 4ea3044f031..131f2c3be38 100644 --- a/zipkin-storage/pom.xml +++ b/zipkin-storage/pom.xml @@ -20,7 +20,7 @@ io.zipkin zipkin-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT io.zipkin.zipkin2 diff --git a/zipkin-tests/pom.xml b/zipkin-tests/pom.xml index e76c1b9d16d..f4c20fb7e2a 100644 --- a/zipkin-tests/pom.xml +++ b/zipkin-tests/pom.xml @@ -20,7 +20,7 @@ io.zipkin zipkin-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT io.zipkin.zipkin2 diff --git a/zipkin/pom.xml b/zipkin/pom.xml index 7e7cc8a889a..861529b669e 100644 --- a/zipkin/pom.xml +++ b/zipkin/pom.xml @@ -20,7 +20,7 @@ io.zipkin zipkin-parent - 3.0.7-SNAPSHOT + 3.1.0-SNAPSHOT io.zipkin.zipkin2