You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@eventmesh.apache.org by "Pil0tXia (via GitHub)" <gi...@apache.org> on 2024/04/14 16:34:11 UTC
Re: [PR] [ISSUE #3430] Refactor eventmesh-metrics-prometheus module (eventmesh)
Pil0tXia commented on code in PR #4840:
URL: https://github.com/apache/eventmesh/pull/4840#discussion_r1564796002
##########
eventmesh-metrics-plugin/eventmesh-metrics-api/src/main/java/org/apache/eventmesh/metrics/api/model/AbstractMetric.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.api.model;
+
+public abstract class AbstractMetric implements Metric {
+
+ private InstrumentFurther further;
Review Comment:
The classes under `org.apache.eventmesh.metrics.api.model` are too many and their inheritance relationship seems a little messy.
>This comment is a copy of https://github.com/apache/eventmesh/pull/3446#discussion_r1450994036
##########
eventmesh-metrics-plugin/eventmesh-metrics-api/src/main/java/org/apache/eventmesh/metrics/api/model/AbstractMetric.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.api.model;
+
+public abstract class AbstractMetric implements Metric {
+
+ private InstrumentFurther further;
Review Comment:
Would it be better to extract implementation classes to a sub-package?
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/MetricInstrumentUnit.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * 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.runtime.metrics;
+
+
+public abstract class MetricInstrumentUnit {
+
+ private MetricInstrumentUnit() {
+
+ }
Review Comment:
We can put this constant class into `constant` package together with `MonitorMetricConstants`.
>This comment is a copy of https://github.com/apache/eventmesh/pull/3446#discussion_r1451026815
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/MetricsManager.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.runtime.metrics;
+
+import org.apache.eventmesh.metrics.api.model.Metric;
+
+import java.util.List;
+
+/**
+ * metric manager interface
+ */
+
+/**
+ * MetricsManager is an interface for managing metrics.
+ */
+public interface MetricsManager {
Review Comment:
duplicate javadoc
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/Pair.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.eventmesh.common;
+
+public class Pair<Left, Right> {
+
+ private Left left;
+
+ private Right right;
Review Comment:
We have two `Pair` classes in our project:
- org.apache.eventmesh.common.Pair
- org.apache.eventmesh.runtime.common.Pair
The usages of the latter one can be unified to the former one.
>This comment is a copy of https://github.com/apache/eventmesh/pull/3446#discussion_r1450992783
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/metrics/GeneralMetricsManager.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.runtime.metrics;
+
+
+import org.apache.eventmesh.metrics.api.MetricsRegistry;
+
+import org.apache.commons.collections4.MapUtils;
+
+import java.util.List;
+import java.util.Map;
+
+import io.opentelemetry.api.common.Attributes;
+import io.opentelemetry.api.common.AttributesBuilder;
+
+import lombok.experimental.UtilityClass;
+
+/**
+ * Managing general metrics.
+ */
+@UtilityClass
+public class GeneralMetricsManager {
Review Comment:
The naming of `GeneralMetricsManager` is a little confusing comparing with `MetricsManager`, and made me think that It's an implementation of `MetricsManager`.
Will putting them in different packages or renaming it to a more suitable name be better?
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/MetricsConstants.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.common;
+
+
+public abstract class MetricsConstants {
+
+ private MetricsConstants() {
+
+ }
Review Comment:
Maybe decorating this constant with `class` is enough, instead of `abstract class`.
The usages of this constant are all in metrics-plugin module, so perhaps placing this class in metrics-plugin module will be better.
>This comment is a copy of https://github.com/apache/eventmesh/pull/3446#discussion_r1450991643
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java:
##########
@@ -134,6 +150,29 @@ public void init() throws Exception {
}
}
+ if (Objects.nonNull(eventMeshTCPServer)) {
+ MetricsManager metricsManager = eventMeshTCPServer.getEventMeshTcpMetricsManager();
+ this.eventMeshMetricsManager.addMetricManager(metricsManager);
+ this.eventMeshMetricsManager.addMetrics(metricsManager.getMetrics());
+ }
+
+ if (Objects.nonNull(eventMeshGrpcServer)) {
+ MetricsManager metricsManager = eventMeshGrpcServer.getEventMeshGrpcMetricsManager();
+ this.eventMeshMetricsManager.addMetricManager(metricsManager);
+ this.eventMeshMetricsManager.addMetrics(metricsManager.getMetrics());
+ }
+
+ if (Objects.nonNull(eventMeshHTTPServer)) {
+ MetricsManager metricsManager = eventMeshHTTPServer.getEventMeshHttpMetricsManager();
+ this.eventMeshMetricsManager.addMetricManager(metricsManager);
+ this.eventMeshMetricsManager.addMetrics(metricsManager.getMetrics());
+ }
Review Comment:
The same `addMetricManager` and `addMetrics` methods are repeated three times, and can be extracted outside of the if condition is not that strict; of course, if the if condition is very strict, it can be left as is.
--
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: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org