-
Notifications
You must be signed in to change notification settings - Fork 62
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
add Sensor to MetricCollector #1171
Merged
qoo332001
merged 14 commits into
opensource4you:main
from
qoo332001:MetricCollectorWithSensor
Dec 6, 2022
Merged
add Sensor to MetricCollector #1171
qoo332001
merged 14 commits into
opensource4you:main
from
qoo332001:MetricCollectorWithSensor
Dec 6, 2022
Conversation
This file contains 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
@qoo332001 終於看到這個功能,很棒。整個專案目前最重要的項目就是如何提升metrics的品質,如同11/25 很多人在詢問我們是透過哪些線索來“處理負載平衡” |
chia7712
reviewed
Nov 27, 2022
common/src/main/java/org/astraea/common/metrics/collector/MetricCollectorImpl.java
Outdated
Show resolved
Hide resolved
chia7712
reviewed
Nov 27, 2022
common/src/main/java/org/astraea/common/metrics/collector/MetricCollectorImpl.java
Outdated
Show resolved
Hide resolved
chia7712
reviewed
Nov 27, 2022
common/src/main/java/org/astraea/common/metrics/collector/MetricCollectorImpl.java
Outdated
Show resolved
Hide resolved
chia7712
reviewed
Nov 27, 2022
chia7712
reviewed
Nov 28, 2022
common/src/main/java/org/astraea/common/metrics/collector/MetricCollector.java
Outdated
Show resolved
Hide resolved
This was referenced Nov 29, 2022
…icCollectorWithSensor
chia7712
reviewed
Nov 30, 2022
common/src/main/java/org/astraea/common/metrics/collector/MetricSensors.java
Outdated
Show resolved
Hide resolved
qoo332001
commented
Dec 2, 2022
common/src/main/java/org/astraea/common/metrics/collector/MetricCollectorImpl.java
Outdated
Show resolved
Hide resolved
chia7712
reviewed
Dec 2, 2022
common/src/main/java/org/astraea/common/metrics/collector/MetricSensors.java
Outdated
Show resolved
Hide resolved
chia7712
reviewed
Dec 2, 2022
common/src/main/java/org/astraea/common/metrics/collector/MetricSensors.java
Show resolved
Hide resolved
…icCollectorWithSensor
chia7712
reviewed
Dec 3, 2022
chia7712
reviewed
Dec 5, 2022
common/src/main/java/org/astraea/common/cost/StatisticalBean.java
Outdated
Show resolved
Hide resolved
chia7712
reviewed
Dec 5, 2022
common/src/main/java/org/astraea/common/metrics/collector/MetricCollectorImpl.java
Outdated
Show resolved
Hide resolved
chia7712
approved these changes
Dec 6, 2022
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.
LGTM
麻煩接著試試看用你新增的方法來套用到 cost function,自我檢驗一下
另外開一PR做對嗎 |
yep |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
此PR結合
MetricCollector
,ClusterBean
和Sensor
的功能,讓CostFunction
在計算分數時可以透過ClusterBean
拿到Sensor
統計一段時間內的值MetricSensors
,內有一個方法用來處理一種Metrics要如何做統計,以及回傳自行產生的HasBeanObject
MetricCollector
中新增addMetricSensors()
,用來增加現有的MetricSensors
MetricCollector
更新metrics到beans的同時會呼叫各個MetricSensors
中的record方法,並取回由該方法產生的HasBeanObject
儲存到beansClusterBean
中新增兩個方法分別可以用來取得TopicPartitionReplica
level 與 broker level透過Sensor計算出來的統計資料目前如何統計使用Sensor統計這些
HasBeanObject
會完全交給CostFunction
來決定,因此如果需要使用自行統計後的值會需要先實做一個方法CostFunction#sensors()
,這個方法會需要回傳Collection,每個MetricsSensors
會紀錄"一種Metrics"(ex. BytesInPerSec, Size),每一種Metrics可能會有多個Sensors(看metrics種類,有可能是一個replica對應一個Sensor或是一個Broker對應一個Sensor),MetricsSensors
中有一個方法record需要實做,每當MetricsCollector
那邊收集到新的metrics時,會將identitiy與其收集到的一包metrics送進MetricsSensors#record
進行自訂的統計,統計後會回傳一個CostFUnction中自行產生的,統計後的HasBeanObject
,最後存到MetricCollector
中,當CostFunction要取用時,可以透過ClusterBean
來獲取一個實做
MetricsSensors#record
的範例:CostFunction會回傳的自訂HasBeanObject,實做如下: