From aaa403ec0035cf5cd470d99d7b3883fcd6e8aff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=99=9F=20Wu=20Sheng?= Date: Mon, 7 Jan 2019 09:48:53 +0800 Subject: [PATCH] Set telemetry module and APIs (#2123) * Finish the APIs of telemetry module. * Add prometheus license. * Active default telemetry provider. --- apm-dist/release-docs/LICENSE | 1 + docker/config/application.yml | 2 + oap-server/pom.xml | 1 + oap-server/server-core/pom.xml | 16 +++-- .../oap/server/core/CoreModuleProvider.java | 3 +- .../src/main/assembly/application.yml | 2 + .../src/main/resources/application.yml | 2 + oap-server/server-telemetry/pom.xml | 36 +++++++++++ .../server-telemetry/telemetry-api/pom.xml | 40 ++++++++++++ .../oap/server/telemetry/TelemetryModule.java | 39 ++++++++++++ .../server/telemetry/api/CounterMetric.java | 40 ++++++++++++ .../oap/server/telemetry/api/GaugeMetric.java | 50 +++++++++++++++ .../server/telemetry/api/HistogramMetric.java | 62 +++++++++++++++++++ .../server/telemetry/api/MetricCreator.java | 60 ++++++++++++++++++ .../oap/server/telemetry/api/MetricTag.java | 58 +++++++++++++++++ .../server/telemetry/api/TaggableMetric.java | 28 +++++++++ .../api/TelemetryRelatedContext.java | 46 ++++++++++++++ .../telemetry/none/MetricCreatorNoop.java | 41 ++++++++++++ .../telemetry/none/NoneTelemetryProvider.java | 59 ++++++++++++++++++ ...ing.oap.server.library.module.ModuleDefine | 19 ++++++ ...g.oap.server.library.module.ModuleProvider | 19 ++++++ .../telemetry-prometheus/pom.xml | 54 ++++++++++++++++ 22 files changed, 672 insertions(+), 6 deletions(-) create mode 100644 oap-server/server-telemetry/pom.xml create mode 100644 oap-server/server-telemetry/telemetry-api/pom.xml create mode 100644 oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/TelemetryModule.java create mode 100644 oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/CounterMetric.java create mode 100644 oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/GaugeMetric.java create mode 100644 oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/HistogramMetric.java create mode 100644 oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricCreator.java create mode 100644 oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricTag.java create mode 100644 oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/TaggableMetric.java create mode 100644 oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/TelemetryRelatedContext.java create mode 100644 oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/MetricCreatorNoop.java create mode 100644 oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/NoneTelemetryProvider.java create mode 100644 oap-server/server-telemetry/telemetry-api/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleDefine create mode 100644 oap-server/server-telemetry/telemetry-api/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider create mode 100644 oap-server/server-telemetry/telemetry-prometheus/pom.xml diff --git a/apm-dist/release-docs/LICENSE b/apm-dist/release-docs/LICENSE index 3d9e723d6..b1faa2baa 100644 --- a/apm-dist/release-docs/LICENSE +++ b/apm-dist/release-docs/LICENSE @@ -306,6 +306,7 @@ The text of each license is the standard Apache 2.0 license. proto files from istio/api: https://github.com/istio/api Apache 2.0 consul-client 1.2.6: https://github.com/rickfast/consul-client, Apache 2.0 okhttp 3.9.0: https://github.com/square/okhttp, Apache 2.0 + prometheus client_java 0.6.0: https://github.com/prometheus/client_java, Apache 2.0 ======================================================================== MIT licenses diff --git a/docker/config/application.yml b/docker/config/application.yml index 842b142ff..1a13b4cff 100644 --- a/docker/config/application.yml +++ b/docker/config/application.yml @@ -95,3 +95,5 @@ query: path: ${SW_QUERY_GRAPHQL_PATH:/graphql} alarm: default: +telemetry: + none: \ No newline at end of file diff --git a/oap-server/pom.xml b/oap-server/pom.xml index 28ad1b69f..040deb3a5 100644 --- a/oap-server/pom.xml +++ b/oap-server/pom.xml @@ -40,6 +40,7 @@ server-testing generated-analysis generate-tool + server-telemetry diff --git a/oap-server/server-core/pom.xml b/oap-server/server-core/pom.xml index 97cd6b2be..9c4075eee 100644 --- a/oap-server/server-core/pom.xml +++ b/oap-server/server-core/pom.xml @@ -34,16 +34,17 @@ org.yaml snakeyaml - - io.grpc - grpc-testing - test - + org.apache.skywalking library-module ${project.version} + + org.apache.skywalking + telemetry-api + ${project.version} + org.apache.skywalking library-util @@ -75,6 +76,11 @@ ${project.version} test + + io.grpc + grpc-testing + test + diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java index 93cfa8088..3eb387e1b 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java @@ -42,6 +42,7 @@ import org.apache.skywalking.oap.server.library.module.*; import org.apache.skywalking.oap.server.library.server.ServerException; import org.apache.skywalking.oap.server.library.server.grpc.GRPCServer; import org.apache.skywalking.oap.server.library.server.jetty.JettyServer; +import org.apache.skywalking.oap.server.telemetry.TelemetryModule; import org.slf4j.*; /** @@ -177,6 +178,6 @@ public class CoreModuleProvider extends ModuleProvider { @Override public String[] requiredModules() { - return new String[0]; + return new String[] {TelemetryModule.NAME}; } } diff --git a/oap-server/server-starter/src/main/assembly/application.yml b/oap-server/server-starter/src/main/assembly/application.yml index 732401213..746de629b 100644 --- a/oap-server/server-starter/src/main/assembly/application.yml +++ b/oap-server/server-starter/src/main/assembly/application.yml @@ -95,3 +95,5 @@ query: path: ${SW_QUERY_GRAPHQL_PATH:/graphql} alarm: default: +telemetry: + none: \ No newline at end of file diff --git a/oap-server/server-starter/src/main/resources/application.yml b/oap-server/server-starter/src/main/resources/application.yml index 4312eba64..d352526d7 100644 --- a/oap-server/server-starter/src/main/resources/application.yml +++ b/oap-server/server-starter/src/main/resources/application.yml @@ -95,3 +95,5 @@ query: path: ${SW_QUERY_GRAPHQL_PATH:/graphql} alarm: default: +telemetry: + none: diff --git a/oap-server/server-telemetry/pom.xml b/oap-server/server-telemetry/pom.xml new file mode 100644 index 000000000..72897f995 --- /dev/null +++ b/oap-server/server-telemetry/pom.xml @@ -0,0 +1,36 @@ + + + + + + oap-server + org.apache.skywalking + 6.0.0-GA-SNAPSHOT + + 4.0.0 + + server-telemetry + pom + + telemetry-prometheus + telemetry-api + + \ No newline at end of file diff --git a/oap-server/server-telemetry/telemetry-api/pom.xml b/oap-server/server-telemetry/telemetry-api/pom.xml new file mode 100644 index 000000000..4a468722d --- /dev/null +++ b/oap-server/server-telemetry/telemetry-api/pom.xml @@ -0,0 +1,40 @@ + + + + + + server-telemetry + org.apache.skywalking + 6.0.0-GA-SNAPSHOT + + 4.0.0 + + telemetry-api + + + org.apache.skywalking + library-module + ${project.version} + + + + + \ No newline at end of file diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/TelemetryModule.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/TelemetryModule.java new file mode 100644 index 000000000..f0f51c960 --- /dev/null +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/TelemetryModule.java @@ -0,0 +1,39 @@ +/* + * 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.telemetry; + +import org.apache.skywalking.oap.server.library.module.ModuleDefine; +import org.apache.skywalking.oap.server.telemetry.api.MetricCreator; + +/** + * Telemetry module definition + * + * @author wusheng + */ +public class TelemetryModule extends ModuleDefine { + public static final String NAME = "telemetry"; + + public TelemetryModule() { + super(NAME); + } + + @Override public Class[] services() { + return new Class[] {MetricCreator.class}; + } +} diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/CounterMetric.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/CounterMetric.java new file mode 100644 index 000000000..944872a1f --- /dev/null +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/CounterMetric.java @@ -0,0 +1,40 @@ +/* + * 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.telemetry.api; + +/** + * A counter is a cumulative metric that represents a single monotonically increasing counter whose value can only + * increase or be reset to zero on restart. For example, you can use a counter to represent the number of requests + * served, tasks completed, or errors.z + * + * @author wusheng + */ +public interface CounterMetric extends TaggableMetric { + /** + * Increase 1 to counter + */ + void inc(); + + /** + * Increase the given value to the counter + * + * @param value + */ + void inc(double value); +} diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/GaugeMetric.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/GaugeMetric.java new file mode 100644 index 000000000..4fd9bfb92 --- /dev/null +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/GaugeMetric.java @@ -0,0 +1,50 @@ +/* + * 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.telemetry.api; + +/** + * A gauge is a metric that represents a single numerical value that can arbitrarily go up and down. + * + * @author wusheng + */ +public interface GaugeMetric extends TaggableMetric { + /** + * Increase 1 to counter + */ + void inc(); + + /** + * Increase the given value to the counter + * + * @param value + */ + void inc(double value); + + /** + * Decrease 1 to counter + */ + void dec(); + + /** + * Decrease the given value to the counter + * + * @param value + */ + void dec(double value); +} diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/HistogramMetric.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/HistogramMetric.java new file mode 100644 index 000000000..240a31884 --- /dev/null +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/HistogramMetric.java @@ -0,0 +1,62 @@ +/* + * 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.telemetry.api; + +import java.io.*; + +/** + * A histogram samples observations (usually things like request durations or response sizes) and counts them in + * configurable buckets. It also provides a sum of all observed values. + * + * @author wusheng + */ +public abstract class HistogramMetric implements TaggableMetric { + public Timer createTimer() { + return new Timer(this); + } + + /** + * Observe an execution, get a duration in second. + * + * @param value duration in second. + */ + public abstract void observe(double value); + + class Timer implements Closeable { + private final HistogramMetric metric; + private final long startNanos; + private double duration; + + public Timer(HistogramMetric metric) { + this.metric = metric; + startNanos = System.nanoTime(); + } + + public void finish() { + long endNanos = System.nanoTime(); + duration = (double)(endNanos - startNanos) / 1.0E9D; + metric.observe(duration); + } + + @Override + public void close() throws IOException { + finish(); + } + } +} diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricCreator.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricCreator.java new file mode 100644 index 000000000..591d67bb2 --- /dev/null +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricCreator.java @@ -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. + * + */ + +package org.apache.skywalking.oap.server.telemetry.api; + +import org.apache.skywalking.oap.server.library.module.Service; + +/** + * Open API to telemetry module, allow to create metric instance with different type. Types inherits from prometheus + * project, and plan to move to openmetrics APIs after it is ready. + * + * @author wusheng + */ +public interface MetricCreator extends Service { + /** + * Create a counter type metric instance. + * + * @param name + * @param tips + * @param labels + * @return + */ + CounterMetric createCounter(String name, String tips, MetricTag.Keys labels); + + /** + * Create a gauge type metric instance. + * + * @param name + * @param tips + * @param labels + * @return + */ + GaugeMetric createGauge(String name, String tips, MetricTag.Keys labels); + + /** + * Create a Histogram type metric instance. + * + * @param name + * @param tips + * @param labels + * @param buckets Time bucket for duration. + * @return + */ + HistogramMetric createHistogramMetric(String name, String tips, MetricTag.Keys labels, double... buckets); +} diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricTag.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricTag.java new file mode 100644 index 000000000..cd5b6b4b4 --- /dev/null +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricTag.java @@ -0,0 +1,58 @@ +/* + * 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.telemetry.api; + +/** + * Tag for the target metric. + * + * The tag values should be set in putting value phase. + */ +public class MetricTag { + public class Keys { + private String[] keys; + + public Keys() { + this.keys = new String[0]; + } + + public Keys(String... keys) { + this.keys = keys; + } + + public String[] getKeys() { + return keys; + } + } + + public class Values { + private String[] values; + + public Values(Keys keys) { + this.values = new String[0]; + } + + public Values(String... keys) { + this.values = keys; + } + + public String[] getValues() { + return values; + } + } +} diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/TaggableMetric.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/TaggableMetric.java new file mode 100644 index 000000000..ade3ff519 --- /dev/null +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/TaggableMetric.java @@ -0,0 +1,28 @@ +/* + * 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.telemetry.api; + +/** + * Set tag values to this metric instance. + * + * @author wusheng + */ +public interface TaggableMetric { + void setTagValues(MetricTag.Values values); +} diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/TelemetryRelatedContext.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/TelemetryRelatedContext.java new file mode 100644 index 000000000..a37e64750 --- /dev/null +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/TelemetryRelatedContext.java @@ -0,0 +1,46 @@ +/* + * 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.telemetry.api; + +/** + * The telemetry context which the metric instances may need to know. + * @author wusheng + */ +public enum TelemetryRelatedContext { + INTANCE; + + private volatile String id = "default"; + private TelemetryRelatedContext(){} + + /** + * Set a global ID to represent the current oap instance + */ + public void setId(String id) { + this.id = id; + } + + /** + * Get the oap instance ID, if be set before, otherwise, return `default` string. + * + * @return id + */ + public String getId() { + return id; + } +} diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/MetricCreatorNoop.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/MetricCreatorNoop.java new file mode 100644 index 000000000..c33dda797 --- /dev/null +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/MetricCreatorNoop.java @@ -0,0 +1,41 @@ +/* + * 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.telemetry.none; + +import org.apache.skywalking.oap.server.telemetry.api.*; + +/** + * A no-op metric create, just create nut shell metric instance. + * + * @author wusheng + */ +public class MetricCreatorNoop implements MetricCreator { + @Override public CounterMetric createCounter(String name, String tips, MetricTag.Keys labels) { + return null; + } + + @Override public GaugeMetric createGauge(String name, String tips, MetricTag.Keys labels) { + return null; + } + + @Override + public HistogramMetric createHistogramMetric(String name, String tips, MetricTag.Keys labels, double... buckets) { + return null; + } +} diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/NoneTelemetryProvider.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/NoneTelemetryProvider.java new file mode 100644 index 000000000..2fd8123fb --- /dev/null +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/NoneTelemetryProvider.java @@ -0,0 +1,59 @@ +/* + * 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.telemetry.none; + +import org.apache.skywalking.oap.server.library.module.*; +import org.apache.skywalking.oap.server.telemetry.TelemetryModule; +import org.apache.skywalking.oap.server.telemetry.api.MetricCreator; + +/** + * A nutshell telemetry implementor. + * + * @author wusheng + */ +public class NoneTelemetryProvider extends ModuleProvider { + @Override public String name() { + return "none"; + } + + @Override public Class module() { + return TelemetryModule.class; + } + + @Override public ModuleConfig createConfigBeanIfAbsent() { + return new ModuleConfig() { + }; + } + + @Override public void prepare() throws ServiceNotProvidedException, ModuleStartException { + this.registerServiceImplementation(MetricCreator.class, new MetricCreatorNoop()); + } + + @Override public void start() throws ServiceNotProvidedException, ModuleStartException { + + } + + @Override public void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException { + + } + + @Override public String[] requiredModules() { + return new String[0]; + } +} diff --git a/oap-server/server-telemetry/telemetry-api/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleDefine b/oap-server/server-telemetry/telemetry-api/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleDefine new file mode 100644 index 000000000..8c0ab8bef --- /dev/null +++ b/oap-server/server-telemetry/telemetry-api/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleDefine @@ -0,0 +1,19 @@ +# +# 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. +# +# + +org.apache.skywalking.oap.server.telemetry.TelemetryModule diff --git a/oap-server/server-telemetry/telemetry-api/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider b/oap-server/server-telemetry/telemetry-api/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider new file mode 100644 index 000000000..f266fc875 --- /dev/null +++ b/oap-server/server-telemetry/telemetry-api/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider @@ -0,0 +1,19 @@ +# +# 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. +# +# + +org.apache.skywalking.oap.server.telemetry.none.NoneTelemetryProvider \ No newline at end of file diff --git a/oap-server/server-telemetry/telemetry-prometheus/pom.xml b/oap-server/server-telemetry/telemetry-prometheus/pom.xml new file mode 100644 index 000000000..7885f9bf9 --- /dev/null +++ b/oap-server/server-telemetry/telemetry-prometheus/pom.xml @@ -0,0 +1,54 @@ + + + + + + server-telemetry + org.apache.skywalking + 6.0.0-GA-SNAPSHOT + + 4.0.0 + + telemetry-prometheus + jar + + + + + io.prometheus + simpleclient + 0.6.0 + + + + io.prometheus + simpleclient_hotspot + 0.6.0 + + + + io.prometheus + simpleclient_httpserver + 0.6.0 + + + + \ No newline at end of file