-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat(op-service): complete separation of op-node/op-service metrics #10545
Conversation
WalkthroughWalkthroughThe recent changes focus on consolidating and refactoring the metrics handling within the Changes
Recent Review DetailsConfiguration used: .coderabbit.yml Files selected for processing (7)
Files skipped from review due to trivial changes (1)
Additional comments not posted (2)
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 (
|
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @hamdiallam and the rest of your teammates on |
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.
Actionable comments posted: 0
Out of diff range and nitpick comments (30)
op-service/testutils/mock_rpc.go (6)
20-22
: Ensure that theClose
method is properly tested to verify that it correctly calls the mock'sCalled
method.
28-31
: Consider adding more detailed comments to explain the purpose of theCallContext
method and how the mock'sCalled
method is used to simulate the behavior.
37-40
: Ensure that theBatchCallContext
method is properly tested to verify that it correctly handles batch calls and returns the appropriate error.
62-65
: Ensure that theEthSubscribe
method is properly tested to verify that it correctly handles subscriptions and returns the appropriate subscription and error.
33-35
: Consider adding more detailed comments to explain the purpose of theExpectCallContext
method and how the mock'sOn
method is used to set expectations for theCallContext
method.
42-60
: Ensure that theExpectBatchCallContext
method is properly tested to verify that it correctly sets expectations for batch calls and handles the mutation of arguments.op-service/metrics/rpc_metrics.go (8)
33-39
: Ensure that theRPCClientMetrics
struct is properly tested to verify that it correctly tracks client RPC metrics using Prometheus counters and histograms.
41-44
: Ensure that theRPCServerMetrics
struct is properly tested to verify that it correctly tracks server RPC metrics using Prometheus counters and histograms.
46-50
: Ensure that theRPCMetrics
struct is properly tested to verify that it correctly combines both client and server metrics.
Line range hint
161-171
: Ensure that theNoopRPCMetrics
struct is properly tested to verify that it correctly implements theRPCMetricer
interface with no-op methods.
52-58
: Ensure that theMakeRPCMetrics
function is properly tested to verify that it correctly creates and initializes anRPCMetrics
instance with the given namespace and factory.
Line range hint
60-93
: Ensure that theMakeRPCClientMetrics
function is properly tested to verify that it correctly creates and initializes anRPCClientMetrics
instance with the given namespace and factory.
128-149
: Ensure that theMakeRPCServerMetrics
function is properly tested to verify that it correctly creates and initializes anRPCServerMetrics
instance with the given namespace and factory.
Line range hint
110-127
: Consider adding more detailed comments to explain the purpose of theRecordRPCClientResponse
function and how it converts errors into metrics-friendly strings.op-service/client/rpc.go (7)
Line range hint
173-187
: Ensure that theBaseRPCClient
struct is properly tested to verify that it correctly wraps anrpc.Client
instance and sets appropriate timeouts for RPC calls.
188-191
: Ensure that theInstrumentedRPCClient
struct is properly tested to verify that it correctly tracks Prometheus metrics for each RPC call.
Line range hint
25-28
: Consider adding more detailed comments to explain the purpose of therpcConfig
struct and how its fields are used to configure RPC clients.
Line range hint
75-91
: Ensure that theNewRPC
function is properly tested to verify that it correctly creates and configures an RPC client with the given options.
Line range hint
94-99
: Ensure that theNewRPCWithClient
function is properly tested to verify that it correctly wraps an existing RPC client with additional functionality, such as polling.
Line range hint
102-122
: Ensure that thedialRPCClientWithBackoff
function is properly tested to verify that it correctly handles dialing an RPC endpoint with exponential backoff.
Line range hint
224-237
: Consider adding more detailed comments to explain the purpose of theinstrumentBatch
function and how it tracks metrics for batch RPC calls.op-service/client/client.go (3)
57-69
: Ensure that theInstrumentedClient
struct is properly tested to verify that it correctly tracks Prometheus metrics for each Ethereum client call.
Line range hint
17-53
: Consider adding more detailed comments to explain the purpose of theClient
interface and how its methods are used for various blockchain-related operations.
65-69
: Ensure that theNewInstrumentedClient
function is properly tested to verify that it correctly creates and initializes anInstrumentedClient
instance with the given RPC client and metrics.op-service/testutils/mock_client.go (6)
22-24
: Ensure that theClose
method is properly tested to verify that it correctly calls the mock'sCalled
method.
30-33
: Consider adding more detailed comments to explain the purpose of theRPC
method and how the mock'sCalled
method is used to simulate the behavior.
39-42
: Ensure that theChainID
method is properly tested to verify that it correctly returns the expected chain ID and error.
48-51
: Ensure that theBlockByHash
method is properly tested to verify that it correctly returns the expected block and error.
102-105
: Ensure that theTransactionByHash
method is properly tested to verify that it correctly returns the expected transaction, pending status, and error.
273-276
: Ensure that theCallContract
method is properly tested to verify that it correctly returns the expected result and error.
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! Nice work
client.RPC
&client.Client
are unusable outside of op-node as the instrumented versions contain dependencies on op-node metrics.Client#RPC()
method allowing a caller to get a instrumented RPC instance from the instrumented eth client.