-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ISSUE #3430]Refactor eventmesh-metrics-prometheus module #3446
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3446 +/- ##
============================================
- Coverage 17.82% 17.29% -0.54%
- Complexity 1514 1518 +4
============================================
Files 604 633 +29
Lines 25559 26413 +854
Branches 2400 2414 +14
============================================
+ Hits 4556 4568 +12
- Misses 20564 21403 +839
- Partials 439 442 +3
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I will try fix the License Check not pass and resubmit later, But reviewer can do review work first if you have time to this work. thanks |
b27fee6
to
3a17b8b
Compare
3a17b8b
to
34c25f0
Compare
I will refactor this pr code and resubmit |
f68ab89
to
06dc8b7
Compare
e987993
to
f77cb70
Compare
@xwm1992 PTAL~ |
@Pil0tXia I'm sorry about that I'm not familiar with this module for now, and in fact I do not have permission to perform an effective approving or decide merging a PR. If you are worried about potential conflicts during the refactoring of "eventmesh admin", you can try asking for advice from maintainers. They may advise you to refactor first. |
@Pil0tXia There will be a biweekly meeting on Thursday where I can bring up this issue. Since it involves some refactoring, I will explain the problem during the meeting. Meanwhile, I will provide the corresponding documentation to the community as soon as possible. Additionally, everyone can help by reviewing the code. Let's aim to have the community merge this pull request as soon as possible. |
@pandaapo The refactoring of the admin on his side is not a major issue, and my pull request may be merged before his. He can simply rebase his branch onto the master branch when the time comes, but this process may involve resolving conflicts. The overall changes related to observability are quite significant. The main upgrades are due to version changes, resulting in differences from the previous approach. There is also a re-design of the top-level interface, among other things. |
Do you mean that the development of refactoring "admin" can be concurrent with the rest works of this PR? |
Concurrent work is technically feasible, while refactoring after this PR is merged will have fewer conflicts. I will start refactoring maybe 1 month later. Not so urgent. |
ce0aa44
to
a5fca9d
Compare
5824674
to
79324ad
Compare
chinese document about metrics. The documentation will be updated on the official website as part of the code merge and subsequent PR submission. Additionally, further optimizations will be made to improve the documentation. |
29c98d4
to
9856c70
Compare
@mxsm Hi~ EventMesh master often throws this exception during normal operation, a feedback to you~ |
Thanks for your feedback, I will try to find it and fix |
…not download some jar package
9856c70
to
005b880
Compare
Any progress we can make here? |
@Pil0tXia |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I didn't see any major vulnerabilities, but there are quite a few code additions related to metrics in the EventMeshServer, which doesn't seem very maintainable.
Additionally, the org.apache.eventmesh.runtime.metrics
and org.apache.eventmesh.metrics.api.model
packages could be made clearer.
package org.apache.eventmesh.common; | ||
|
||
|
||
public abstract class MetricsConstants { | ||
|
||
private MetricsConstants() { | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
package org.apache.eventmesh.common; | ||
|
||
public class Pair<Left, Right> { | ||
|
||
private Left left; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
package org.apache.eventmesh.metrics.api.model; | ||
|
||
public abstract class AbstractMetric implements Metric { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The classes under org.apache.eventmesh.metrics.api.model
are too many and their inheritance relationship seems a little messy.
eventMeshHttpServer = new EventMeshHTTPServer(eventMeshServer, eventMeshHttpConfiguration); | ||
eventMeshHttpServer.init(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to init eventMeshHttpServer here?
} | ||
List<String> metricsPluginTypes = configuration.getEventMeshMetricsPluginType(); | ||
if (CollectionUtils.isNotEmpty(metricsPluginTypes)) { | ||
List<MetricsRegistry> metricsRegistries = metricsPluginTypes.stream().map(metric -> MetricsPluginFactory.getMetricsRegistry(metric)) | ||
.collect(Collectors.toList()); | ||
eventMeshMetricsManager = new EventMeshMetricsManager(metricsRegistries); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that maybe it is not a good design to place a list of metrics plugin types here. Is there a similar way to init metrics like other plugins (L79~L83)?
if (StringUtils.isBlank(heartbeatRequestHeader.getIdc()) | ||
|| StringUtils.isBlank(heartbeatRequestHeader.getPid()) | ||
|| !StringUtils.isNumeric(heartbeatRequestHeader.getPid()) | ||
|| StringUtils.isBlank(heartbeatRequestHeader.getSys())) { | ||
responseEventMeshCommand = asyncContext.getRequest().createHttpCommandResponse( | ||
heartbeatResponseHeader, | ||
HeartbeatResponseBody.buildBody(EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getRetCode(), | ||
EventMeshRetCode.EVENTMESH_PROTOCOL_HEADER_ERR.getErrMsg())); | ||
asyncContext.onComplete(responseEventMeshCommand); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the main change here is the invocation of createHttpCommandResponse
. What are the advantages of the validation logic here compared to the original? Bringing a more comprehensive validation logic?
|
||
public abstract class MetricInstrumentUnit { | ||
|
||
private MetricInstrumentUnit() { | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can put this constant class into constant
package together with MonitorMetricConstants
.
@Slf4j | ||
class TcpMetricsCalculator { | ||
|
||
private static final int period = 30 * 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why TCP needs a "Calculator" comparing to HTTP and gRPC?
/** | ||
* metric manager interface | ||
*/ | ||
|
||
/** | ||
* MetricsManager is an interface for managing metrics. | ||
*/ | ||
public interface MetricsManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate javadoc
/** | ||
* Managing general metrics. | ||
*/ | ||
@UtilityClass | ||
public class GeneralMetricsManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming of GeneralMetricsManager
is a little confusing comparing with MetricsManager
. How about putting them in different packages and rename it to a more suitable name?
@Pil0tXia This PR has been open for too long, and many code changes make resolving conflicts during refactoring challenging. I will submit a new PR based on the latest code. The overall design will still be based on the current PR, and I will address the issues you mentioned above one by one. |
This pr will be closed, the new is #4840 |
Fixes #3430
Motivation
Modifications
Refactor eventmesh-metrics-prometheus module
![image](https://user-images.githubusercontent.com/15797831/224758329-e706ec09-4f01-4108-9680-d9d0ab25da73.png)
Documentation