You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/03/06 09:36:05 UTC
[incubator-skywalking] branch envoy-metric updated: Make test env
works.
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch envoy-metric
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
The following commit(s) were added to refs/heads/envoy-metric by this push:
new 032bc93 Make test env works.
032bc93 is described below
commit 032bc934a6fc10772321afc2a955ff6b1e1bfd39
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Mar 6 17:35:54 2019 +0800
Make test env works.
---
docker/config/application.yml | 2 +
.../envoy/MetricServiceGRPCHandlerTestMain.java | 93 ++++++++++++++++++++++
.../src/test/resources/envoy-metric.msg | 60 ++++++++++++++
oap-server/server-starter/pom.xml | 5 ++
.../src/main/assembly/application.yml | 18 +++--
.../src/main/resources/application.yml | 2 +
6 files changed, 172 insertions(+), 8 deletions(-)
diff --git a/docker/config/application.yml b/docker/config/application.yml
index d99357a..fa4cbb6 100644
--- a/docker/config/application.yml
+++ b/docker/config/application.yml
@@ -86,6 +86,8 @@ service-mesh:
bufferFileCleanWhenRestart: ${SW_SERVICE_MESH_BUFFER_FILE_CLEAN_WHEN_RESTART:false}
istio-telemetry:
default:
+envoy-metric:
+ default:
# receiver_zipkin:
# default:
# host: ${SW_RECEIVER_ZIPKIN_HOST:0.0.0.0}
diff --git a/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/test/java/org/apache/skywalking/oap/server/receiver/envoy/MetricServiceGRPCHandlerTestMain.java b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/test/java/org/apache/skywalking/oap/server/receiver/envoy/MetricServiceGRPCHandlerTestMain.java
new file mode 100644
index 0000000..8a7caa6
--- /dev/null
+++ b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/test/java/org/apache/skywalking/oap/server/receiver/envoy/MetricServiceGRPCHandlerTestMain.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.oap.server.receiver.envoy;
+
+import com.google.protobuf.TextFormat;
+import io.envoyproxy.envoy.service.metrics.v2.*;
+import io.grpc.*;
+import io.grpc.stub.StreamObserver;
+import io.prometheus.client.Metrics;
+import java.io.*;
+import java.util.concurrent.*;
+
+/**
+ * @author wusheng
+ */
+public class MetricServiceGRPCHandlerTestMain {
+
+ public static void main(String[] args) throws InterruptedException {
+ ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 11800).usePlaintext(true).build();
+
+ MetricsServiceGrpc.MetricsServiceStub stub = MetricsServiceGrpc.newStub(channel);
+
+ ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
+ executor.schedule(() -> {
+ try {
+ send(stub);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }, 1, TimeUnit.SECONDS);
+ Thread.sleep(5000L);
+ executor.shutdown();
+ }
+
+ private static void send(
+ final MetricsServiceGrpc.MetricsServiceStub stub) throws IOException, InterruptedException {
+ StreamObserver<StreamMetricsMessage> messageStreamObserver = stub.streamMetrics(new StreamObserver<StreamMetricsResponse>() {
+ @Override public void onNext(StreamMetricsResponse response) {
+
+ }
+
+ @Override public void onError(Throwable throwable) {
+
+ }
+
+ @Override public void onCompleted() {
+
+ }
+ });
+ int countdown = 20;
+ while (countdown-- > 0) {
+ try (InputStreamReader isr = new InputStreamReader(getResourceAsStream("envoy-metric.msg"))) {
+ StreamMetricsMessage.Builder requestBuilder = StreamMetricsMessage.newBuilder();
+ TextFormat.getParser().merge(isr, requestBuilder);
+
+ for (Metrics.MetricFamily.Builder builder : requestBuilder.getEnvoyMetricsBuilderList()) {
+ for (Metrics.Metric.Builder metricBuilder : builder.getMetricBuilderList()) {
+ metricBuilder.setTimestampMs(System.currentTimeMillis());
+ }
+ }
+ messageStreamObserver.onNext(requestBuilder.build());
+ Thread.sleep(200L);
+ }
+ }
+ }
+
+ private static InputStream getResourceAsStream(final String resource) {
+ final InputStream in = getContextClassLoader().getResourceAsStream(resource);
+ return in == null ? MetricServiceGRPCHandlerTestMain.class.getResourceAsStream(resource) : in;
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+}
diff --git a/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/test/resources/envoy-metric.msg b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/test/resources/envoy-metric.msg
new file mode 100644
index 0000000..26b0f1d
--- /dev/null
+++ b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/test/resources/envoy-metric.msg
@@ -0,0 +1,60 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
+identifier {
+ node {
+ id: "ingress",
+ cluster: "envoy-proxy",
+ metadata {
+ fields {
+ key: "envoy"
+ value {
+ string_value: "isawesome"
+ }
+ key: "skywalking"
+ value {
+ string_value: "iscool"
+ }
+ }
+ },
+ locality {
+ region: "ap-southeast-1"
+ zone: "zone1"
+ sub_zone: "subzone1"
+ },
+ build_version: "caf7ab123964cedd172a2d4cb29b2f2e05ca9156/1.10.0-dev/Clean/RELEASE/BoringSSL"
+ }
+}
+envoy_metrics {
+ name: "cluster.service_stats.update_attempt",
+ metric [
+ {
+ counter {
+ value: 1
+ },
+ timestamp_ms: 1551781658343
+ }
+ ]
+ name: "cluster.service_stats.membership_change",
+ metric [
+ {
+ counter {
+ value: 1
+ },
+ timestamp_ms: 1551781658343
+ }
+ ]
+}
\ No newline at end of file
diff --git a/oap-server/server-starter/pom.xml b/oap-server/server-starter/pom.xml
index 7a814d6..36d8192 100644
--- a/oap-server/server-starter/pom.xml
+++ b/oap-server/server-starter/pom.xml
@@ -100,6 +100,11 @@
</dependency>
<dependency>
<groupId>org.apache.skywalking</groupId>
+ <artifactId>envoy-metrics-receiver-plugin</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
<artifactId>zipkin-receiver-plugin</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/oap-server/server-starter/src/main/assembly/application.yml b/oap-server/server-starter/src/main/assembly/application.yml
index b8c0efc..3f12d5a 100644
--- a/oap-server/server-starter/src/main/assembly/application.yml
+++ b/oap-server/server-starter/src/main/assembly/application.yml
@@ -78,14 +78,16 @@ receiver-trace:
slowDBAccessThreshold: ${SW_SLOW_DB_THRESHOLD:default:200,mongodb:100} # The slow database access thresholds. Unit ms.
receiver-jvm:
default:
-#service-mesh:
-# default:
-# bufferPath: ${SW_SERVICE_MESH_BUFFER_PATH:../mesh-buffer/} # Path to trace buffer files, suggest to use absolute path
-# bufferOffsetMaxFileSize: ${SW_SERVICE_MESH_OFFSET_MAX_FILE_SIZE:100} # Unit is MB
-# bufferDataMaxFileSize: ${SW_SERVICE_MESH_BUFFER_DATA_MAX_FILE_SIZE:500} # Unit is MB
-# bufferFileCleanWhenRestart: ${SW_SERVICE_MESH_BUFFER_FILE_CLEAN_WHEN_RESTART:false}
-#istio-telemetry:
-# default:
+service-mesh:
+ default:
+ bufferPath: ${SW_SERVICE_MESH_BUFFER_PATH:../mesh-buffer/} # Path to trace buffer files, suggest to use absolute path
+ bufferOffsetMaxFileSize: ${SW_SERVICE_MESH_OFFSET_MAX_FILE_SIZE:100} # Unit is MB
+ bufferDataMaxFileSize: ${SW_SERVICE_MESH_BUFFER_DATA_MAX_FILE_SIZE:500} # Unit is MB
+ bufferFileCleanWhenRestart: ${SW_SERVICE_MESH_BUFFER_FILE_CLEAN_WHEN_RESTART:false}
+istio-telemetry:
+ default:
+envoy-metric:
+ default:
#receiver_zipkin:
# default:
# host: ${SW_RECEIVER_ZIPKIN_HOST:0.0.0.0}
diff --git a/oap-server/server-starter/src/main/resources/application.yml b/oap-server/server-starter/src/main/resources/application.yml
index 24df981..616cdda 100644
--- a/oap-server/server-starter/src/main/resources/application.yml
+++ b/oap-server/server-starter/src/main/resources/application.yml
@@ -86,6 +86,8 @@ service-mesh:
bufferFileCleanWhenRestart: ${SW_SERVICE_MESH_BUFFER_FILE_CLEAN_WHEN_RESTART:false}
istio-telemetry:
default:
+envoy-metric:
+ default:
#receiver_zipkin:
# default:
# host: ${SW_RECEIVER_ZIPKIN_HOST:0.0.0.0}