You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2022/01/12 10:04:23 UTC

[GitHub] [incubator-eventmesh] xwm1992 commented on a change in pull request #709: [ISSUE #696] Improve metrics exporters' expandability

xwm1992 commented on a change in pull request #709:
URL: https://github.com/apache/incubator-eventmesh/pull/709#discussion_r782822547



##########
File path: eventmesh-metrics-plugin/eventmesh-metrics-api/src/main/java/org/apache/eventmesh/metrics/api/model/Metric.java
##########
@@ -15,20 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.eventmesh.runtime.metrics.http;
+package org.apache.eventmesh.metrics.api.model;
 
-import org.apache.eventmesh.runtime.boot.EventMeshHTTPServer;
-
-import com.codahale.metrics.MetricRegistry;
-
-public class GroupMetrics {
-
-    private EventMeshHTTPServer eventMeshHTTPServer;
-
-    private MetricRegistry metricRegistry;
-
-    public GroupMetrics(EventMeshHTTPServer eventMeshHTTPServer, MetricRegistry metricRegistry) {
-        this.eventMeshHTTPServer = eventMeshHTTPServer;
-        this.metricRegistry = metricRegistry;
-    }
+/**
+ * Top-level metric, all metrics should implement this interface.
+ */
+public interface Metric {

Review comment:
       May be abstract class is more convenient.

##########
File path: eventmesh-metrics-plugin/eventmesh-metrics-opentelemetry/src/main/java/org/apache/eventmesh/metrics/opentelemetry/OpenTelemetryMetricsRegistry.java
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.eventmesh.metrics.opentelemetry;
+
+import org.apache.eventmesh.metrics.api.MetricsRegistry;
+import org.apache.eventmesh.metrics.api.model.HttpSummaryMetrics;
+import org.apache.eventmesh.metrics.api.model.Metric;
+import org.apache.eventmesh.metrics.api.model.TcpSummaryMetrics;
+import org.apache.eventmesh.metrics.opentelemetry.metrics.OpenTelemetryHttpExporter;
+import org.apache.eventmesh.metrics.opentelemetry.metrics.OpenTelemetryTcpExporter;
+
+import java.io.IOException;
+
+import io.opentelemetry.exporter.prometheus.PrometheusCollector;
+import io.opentelemetry.sdk.metrics.SdkMeterProvider;
+import io.prometheus.client.exporter.HTTPServer;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class OpenTelemetryMetricsRegistry implements MetricsRegistry {
+
+    private volatile HTTPServer prometheusHttpServer;
+
+    @Override
+    public void start() {
+        if (prometheusHttpServer == null) {
+            synchronized (OpenTelemetryMetricsRegistry.class) {
+                if (prometheusHttpServer == null) {
+                    SdkMeterProvider sdkMeterProvider = SdkMeterProvider.builder().buildAndRegisterGlobal();
+                    PrometheusCollector
+                        .builder().setMetricProducer(sdkMeterProvider).buildAndRegister();
+                    // todo:
+                    int port = 0;

Review comment:
       Here isn't correct, right?

##########
File path: eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java
##########
@@ -166,14 +164,22 @@ public void init() {
             String eventMeshTraceExportZipkinIpStr =
                     configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_IP);
             Preconditions.checkState(StringUtils.isNotEmpty(eventMeshTraceExportZipkinIpStr),
-                    String.format("%s error", ConfKeys.KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_IP));
+                String.format("%s error", ConfKeys.KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_IP));
             eventMeshTraceExportZipkinIp = StringUtils.deleteWhitespace(eventMeshTraceExportZipkinIpStr);
 
             String eventMeshTraceExportZipkinPortStr =
-                    configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_PORT);
+                configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_PORT);
             if (StringUtils.isNotEmpty(eventMeshTraceExportZipkinPortStr)) {
                 eventMeshTraceExportZipkinPort =
-                        Integer.parseInt(StringUtils.deleteWhitespace(eventMeshTraceExportZipkinPortStr));
+                    Integer.parseInt(StringUtils.deleteWhitespace(eventMeshTraceExportZipkinPortStr));
+            }
+
+            String metricsPluginType = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_METRICS_PLUGIN_TYPE);
+            if (StringUtils.isNotEmpty(metricsPluginType)) {
+                eventMeshMetricsPluginType = Arrays.stream(metricsPluginType.split(","))

Review comment:
       why are arrays used here?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org