daradurvs commented on a change in pull request #6546: IGNITE-11848: New Monitoring. Phase1
URL: https://github.com/apache/ignite/pull/6546#discussion_r291348371
##########
File path: modules/opencensus/src/main/java/org/apache/ignite/internal/processors/monitoring/opencensus/OpenCensusMetricExporterSpi.java
##########
@@ -0,0 +1,279 @@
+/*
+ * 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.ignite.internal.processors.monitoring.opencensus;
+
+import io.opencensus.common.Scope;
+import io.opencensus.stats.Aggregation.LastValue;
+import io.opencensus.stats.Measure;
+import io.opencensus.stats.Measure.MeasureDouble;
+import io.opencensus.stats.Measure.MeasureLong;
+import io.opencensus.stats.MeasureMap;
+import io.opencensus.stats.Stats;
+import io.opencensus.stats.StatsRecorder;
+import io.opencensus.stats.View;
+import io.opencensus.stats.View.Name;
+import io.opencensus.tags.TagContextBuilder;
+import io.opencensus.tags.TagKey;
+import io.opencensus.tags.TagValue;
+import io.opencensus.tags.Tags;
+import java.time.OffsetDateTime;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.metric.PushMetricsExporterAdapter;
+import org.apache.ignite.spi.IgniteSpiContext;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.spi.metric.BooleanMetric;
+import org.apache.ignite.spi.metric.DoubleMetric;
+import org.apache.ignite.spi.metric.IntMetric;
+import org.apache.ignite.spi.metric.LongMetric;
+import org.apache.ignite.spi.metric.Metric;
+import org.apache.ignite.internal.processors.metric.MetricRegistry;
+import org.apache.ignite.spi.metric.ObjectMetric;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * OpenCensus monitoring exporter.
+ *
+ * This class will export all Ignite metrics with the OpenCensus API.
+ *
+ * Please, note, metrics recorded with the OpenCensus API each {@link #period} milliseconds.
+ *
+ * To enable export from OpenCensus to the wild user should configure OpenCensus exporter.
+ * Please, see OpenCensus documentation for additional information.
+ *
+ * Example of exporter configuration:
+ *
+ * {@code + * PrometheusStatsCollector.createAndRegister(); + * + * HTTPServer server = new HTTPServer("localhost", 8888, true); + * } + *+ * + * @see MetricRegistry + */ +public class OpenCensusMetricExporterSpi extends PushMetricsExporterAdapter { + /** Flag to enable or disable tag with Ignite instance name. */ + private boolean sendInstanceName; + + /** Flag to enable or disable tag with Node id. */ + private boolean sendNodeId; + + /** Flag to enable or disable tag with Consistent id. */ + private boolean sendConsistentId; + + /** Ignite instance name. */ + public static final TagKey INSTANCE_NAME_TAG = TagKey.create("iin"); + + /** Ignite node id. */ + public static final TagKey NODE_ID_TAG = TagKey.create("ini"); + + /** Ignite node consistent id. */ + public static final TagKey CONSISTENT_ID_TAG = TagKey.create("inci"); + + /** Ignite instance name in the form of {@link TagValue}. */ + private TagValue instanceNameValue; + + /** Ignite node id in the form of {@link TagValue}. */ + private TagValue nodeIdValue; + + /** Ignite consistent id in the form of {@link TagValue}. */ + private TagValue consistenIdValue; + + /** + * Tags that will be exported with each measure + * + * @see #sendInstanceName + * @see #sendNodeId + */ + private List