-
Notifications
You must be signed in to change notification settings - Fork 148
Revert "[CLOB-1014] [CLOB-1004] Unify metrics library, un-modularize … #967
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
Conversation
WalkthroughThe codebase has undergone a metrics system overhaul, shifting from an in-house metrics package and Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (7)
- protocol/lib/metrics/constants.go (1 hunks)
- protocol/lib/metrics/util.go (2 hunks)
- protocol/x/clob/abci.go (3 hunks)
- protocol/x/clob/keeper/deleveraging.go (8 hunks)
- protocol/x/clob/keeper/liquidations.go (6 hunks)
- protocol/x/clob/keeper/mev.go (9 hunks)
- protocol/x/clob/types/order_id.go (2 hunks)
Additional comments: 31
protocol/lib/metrics/util.go (2)
- 6-6: The import of the
time
package is necessary for the new functionality introduced in theModuleMeasureSinceWithLabels
function.- 71-88: The new function
ModuleMeasureSinceWithLabels
is correctly defined and follows the established pattern of other functions in the file. It uses thegometrics.MeasureSinceWithLabels
function to emit a time measure metric, which is consistent with the metrics package's usage.protocol/x/clob/types/order_id.go (2)
- 9-9: The new import
github.com/armon/go-metrics
is necessary due to the change in the return type of theGetOrderIdLabels
method from[]metrics.Label
to[]gometrics.Label
.- 177-178: The change in the return type of the
GetOrderIdLabels
method from[]metrics.Label
to[]gometrics.Label
is consistent with the new import and the rest of the changes in the PR related to metrics handling.protocol/x/clob/abci.go (3)
- 7-7: The new import
github.com/armon/go-metrics
is consistent with the changes in metrics handling throughout the PR.- 76-79: The replacement of the
metrics
package with thetelemetry
package for incrementing counters is consistent with the PR's objective to revert changes to the metrics system.- 121-124: The use of
telemetry.SetGaugeWithLabels
to set the gauge for the insurance fund balance is consistent with the changes in metrics handling and the addition of theInsuranceFundBalance
constant.protocol/lib/metrics/constants.go (1)
- 316-316: The addition of the
InsuranceFundBalance
constant is consistent with the changes in theabci.go
file and the PR's objectives to update metrics handling.protocol/x/clob/keeper/deleveraging.go (7)
- 9-14: The import changes are consistent with the PR's objective to revert the metrics handling.
- 81-87: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [84-96]
The labels are correctly updated to use
gometrics.Label
and theIncrCounterWithLabels
function is replaced withgometrics.SetGaugeWithLabels
, which aligns with the PR objectives.
- 103-111: The
telemetry.IncrCounterWithLabels
andgometrics.AddSampleWithLabels
functions are used appropriately to record metrics, consistent with the PR's goal.- 120-123: The
gometrics.AddSampleWithLabels
function is used correctly to record the percent filled of the deleveraging operation.- 291-295: The
telemetry.ModuleMeasureSince
function is replaced withdefer
to ensure the metric is recorded after the function execution, which is a good practice for timing metrics.- 431-453: The
gometrics.AddSampleWithLabels
function is used correctly to record various metrics related to the deleveraging process.- 587-595: The
gometrics.AddSampleWithLabels
function is used correctly to record the stat quantums deleveraged in quote quantums.protocol/x/clob/keeper/mev.go (9)
- 9-10: The import changes reflect the switch from
armon/go-metrics
tocosmos/cosmos-sdk/telemetry
, which is consistent with the PR's objective to revert the metrics handling.- 73-73: The
defer
statement has been updated to use thetelemetry
package for metric recording, aligning with the revert of the metrics system.- 112-112: The error handling within the
RecordMevMetrics
function now correctly uses thetelemetry
package to increment the error counter.- 124-124: The error counter incrementation after failing to calculate PnL for block proposer MEV matches has been updated to use the
telemetry
package.- 138-138: The error handling for creating MEV matches for validator operations has been updated to use the
telemetry
package for incrementing the error counter.- 150-150: The error handling for calculating match PnL for the validator has been updated to use the
telemetry
package for incrementing the error counter.- 223-223: The error counter incrementation after failing to get the consensus round has been updated to use the
telemetry
package.- 235-235: The error handling for failing to get the proposer by consensus address now correctly uses the
telemetry
package to increment the error counter.- 290-302: The gauge setting for MEV metrics has been updated to use the
telemetry
package, which is consistent with the changes made throughout the file.protocol/x/clob/keeper/liquidations.go (7)
- 13-13: The import alias
gometrics
forgithub.com/armon/go-metrics
is correctly defined.- 45-50: The change from
metrics.AddSample
togometrics.AddSample
with the updated metric names and labels is correct and aligns with the PR objectives.- 285-285: The update from
metrics.Label
togometrics.Label
is consistent with the changes made throughout the file.- 299-302: The replacement of
metrics.AddSampleWithLabels
withgometrics.AddSampleWithLabels
and the adjustment of the metric names and labels are correct.- 325-328: The switch from
metrics.IncrCounterWithLabels
totelemetry.IncrCounterWithLabels
with the updated metric names and labels is consistent with the PR objectives.- 330-333: The change from
metrics.AddSampleWithLabels
togometrics.AddSampleWithLabels
for the distribution metric is correct.- 593-605: The update from
metrics.IncrCounterWithLabels
totelemetry.IncrCounterWithLabels
with the new labels is consistent with the changes made in other parts of the file.
telemetry.IncrCounter( | ||
1, | ||
types.ModuleName, | ||
metrics.PrepareCheckState, | ||
metrics.CannotDeleverageSubaccount, |
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 telemetry.IncrCounter
function is being used, but according to the PR summary, the usage of cosmos/cosmos-sdk/telemetry
should be replaced with armon/go-metrics
. This instance was not updated.
- telemetry.IncrCounter(
+ gometrics.SetGaugeWithLabels(
Committable suggestion
❗ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
telemetry.IncrCounter( | |
1, | |
types.ModuleName, | |
metrics.PrepareCheckState, | |
metrics.CannotDeleverageSubaccount, | |
gometrics.SetGaugeWithLabels( | |
1, | |
types.ModuleName, | |
metrics.PrepareCheckState, | |
metrics.CannotDeleverageSubaccount, |
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to path filters (2)
protocol/go.mod
is excluded by:!**/*.mod
protocol/go.sum
is excluded by:!**/*.sum
Files selected for processing (1)
- protocol/lib/metrics/lib.go (1 hunks)
Additional comments: 1
protocol/lib/metrics/lib.go (1)
- 69-71: > Note: This review was outside the patches, and no patch overlapping with it was found. Original lines [1-48]
The removal of
ModuleMeasureSinceWithLabels
aligns with the PR's objective to revert changes related to metrics handling. The existing functions provide similar functionality and the TODO comments suggest future improvements for custom calculations.
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (5)
- protocol/x/clob/abci.go (3 hunks)
- protocol/x/clob/keeper/deleveraging.go (8 hunks)
- protocol/x/clob/keeper/liquidations.go (6 hunks)
- protocol/x/clob/keeper/mev.go (10 hunks)
- protocol/x/clob/types/order_id.go (2 hunks)
Files skipped from review as they are similar to previous changes (5)
- protocol/x/clob/abci.go
- protocol/x/clob/keeper/deleveraging.go
- protocol/x/clob/keeper/liquidations.go
- protocol/x/clob/keeper/mev.go
- protocol/x/clob/types/order_id.go
Metrics are not showing up due to commit
9e08e81
/ pr #792 . Revert.EDIT: this was not the issue.