-
Notifications
You must be signed in to change notification settings - Fork 638
[ISSUE #3430] Refactor eventmesh-metrics-prometheus module #4840
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
Merged
xwm1992
merged 3 commits into
apache:master
from
mxsm:eventmesh-refactor-metrics-3430-new
Apr 19, 2024
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
eventmesh-common/src/main/java/org/apache/eventmesh/common/MetricsConstants.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 class MetricsConstants { | ||
|
||
private MetricsConstants() { | ||
|
||
} | ||
|
||
public static final String UNKOWN = "unkown"; | ||
|
||
public static final String LABEL_PROCESSOR = "processor"; | ||
|
||
public static final String CLIENT_ADDRESS = "client.address"; | ||
|
||
public static final String RPC_SYSTEM = "rpc.system"; | ||
|
||
public static final String RPC_SERVICE = "rpc.service"; | ||
|
||
//GRPC-https://opentelemetry.io/docs/reference/specification/metrics/semantic_conventions/rpc-metrics/ | ||
public static final String GRPC_NET_PEER_PORT = "net.peer.port"; | ||
|
||
public static final String GRPC_NET_PEER_NAME = "net.peer.name"; | ||
|
||
public static final String GRPC_NET_SOCK_PEER_ADDR = "net.sock.peer.addr"; | ||
|
||
public static final String GRPC_NET_SOCK_PEER_PORT = "net.sock.peer.port"; | ||
|
||
// HTTP https://opentelemetry.io/docs/reference/specification/metrics/semantic_conventions/http-metrics/ | ||
|
||
public static final String HTTP_HTTP_SCHEME = "http.scheme"; | ||
|
||
public static final String HTTP_HTTP_FLAVOR = "http.flavor"; | ||
|
||
public static final String HTTP_NET_HOST_NAME = "net.host.name"; | ||
|
||
public static final String HTTP_NET_HOST_PORT = "net.host.port"; | ||
|
||
//TCP | ||
public static final String TCP_NET_HOST_NAME = "net.host.name"; | ||
|
||
public static final String TCP_NET_HOST_PORT = "net.host.port"; | ||
|
||
|
||
public static final String CLIENT_PROTOCOL_TYPE = "client.protocol.type"; | ||
|
||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...mesh-metrics-api/src/main/java/org/apache/eventmesh/metrics/api/model/AbstractMetric.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
private String metricName; | ||
|
||
public AbstractMetric(InstrumentFurther further, String metricName) { | ||
this.further = further; | ||
this.metricName = metricName; | ||
} | ||
|
||
public AbstractMetric() { | ||
|
||
} | ||
|
||
@Override | ||
public void setInstrumentFurther(InstrumentFurther further) { | ||
this.further = further; | ||
} | ||
|
||
@Override | ||
public InstrumentFurther getInstrumentFurther() { | ||
return this.further; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return metricName; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
.../src/main/java/org/apache/eventmesh/metrics/api/model/AbstractObservableDoubleMetric.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
|
||
import java.util.function.Supplier; | ||
|
||
public abstract class AbstractObservableDoubleMetric extends AbstractObservableMetric<Double> { | ||
|
||
private Supplier<Double> supplier; | ||
|
||
public AbstractObservableDoubleMetric(InstrumentFurther further, String metricName) { | ||
super(further, metricName); | ||
} | ||
|
||
public AbstractObservableDoubleMetric(InstrumentFurther further, String metricName, Supplier<Double> supplier) { | ||
super(further, metricName); | ||
this.supplier = supplier; | ||
} | ||
|
||
public AbstractObservableDoubleMetric() { | ||
|
||
} | ||
|
||
public void supplier(Supplier<Double> supplier) { | ||
this.supplier = supplier; | ||
} | ||
|
||
@Override | ||
public Supplier<Double> supplier() { | ||
return supplier; | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...pi/src/main/java/org/apache/eventmesh/metrics/api/model/AbstractObservableLongMetric.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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; | ||
|
||
|
||
import java.util.function.Supplier; | ||
|
||
public abstract class AbstractObservableLongMetric extends AbstractObservableMetric<Long> { | ||
|
||
private Supplier<Long> supplier; | ||
|
||
public AbstractObservableLongMetric(InstrumentFurther further, String metricName) { | ||
super(further, metricName); | ||
} | ||
|
||
public AbstractObservableLongMetric(InstrumentFurther further, String metricName, Supplier<Long> supplier) { | ||
super(further, metricName); | ||
this.supplier = supplier; | ||
} | ||
|
||
public AbstractObservableLongMetric() { | ||
|
||
} | ||
|
||
public void supplier(Supplier<Long> supplier) { | ||
this.supplier = supplier; | ||
} | ||
|
||
@Override | ||
public Supplier<Long> supplier() { | ||
return supplier; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.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.
Would it be better to extract implementation classes to a sub-package?
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.
There's no need to put this in a subclass; this covers all implementations. Using an abstract class makes it easier for future extensions.
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 meant to move files location without making changes to the class. The directory structure may like this:
It may be easier to find out how many interfaces and abstract classes are under this package and locate them.
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
model
package is mainly used to store metrics. Personally, I don't think it's necessary to further classify the types of metrics. They can be uniformly placed in this package. Similarly, this package basically includes metrics that adhere to the existing OpenTelemetry specification. Being too granular makes the code look bloated.