-
Notifications
You must be signed in to change notification settings - Fork 246
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 some more metrics #620
Merged
Merged
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
CHr15F0x
commented
Sep 20, 2022
CHr15F0x
commented
Sep 20, 2022
CHr15F0x
commented
Sep 20, 2022
9a4f307
to
e6e6681
Compare
Mirko-von-Leipzig
approved these changes
Sep 21, 2022
Meta: should we be testing these metrics? It adds a lot of extra code; is it worth it? |
|
kkovaacs
approved these changes
Sep 22, 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 other than that small naming nitpick.
And protect from test interference.
Because this test calls `sequencer::Client::block`.
368216a
to
6eda060
Compare
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.
This PR adds more counters. The vast majority of the PR content is tests for those, I tried to keep the production code delta as small as possible. Any ideas for more metrics will be put into a separate PR.
The number of commits is pretty big but I recommend going through the code on a per-file basis and skipping the tests first.
RPC counters
rpc_method_calls_total
, uses amethod
label to distinguish between RPC methodsSequencer counters
sequencer_requests_total
sequencer_requests_failed_total
EDIT: failure reasons are labels now
sequencer_requests_failed_starknet_total
- requests failed due to StarkNet specific errorssequencer_requests_failed_decode_total
- requests failed due to deserialization errorssequencer_requests_failed_rate_limited_total
- requests failed due to rate limitingmethod
label to distinguish between request types (get_block
,get_state_updates
, etc.).get_block
,get_state_updates
can use atag
label which is eitherlatest
orpending
.reason
label, with the following values:a.
decode
- requests failed due to deserialization errorsb.
starknet
- requests failed due to StarkNet specific errorsc.
rate_limiting
- requests failed due to rate limitingsequencer_requests_failed_decode_total
decode
is in the readme too, but long story short - once in a while these happen in bursts because of a cairo lang update and I imagine users would like to filter those out to avoid obfuscating the failures that happen on a daily basis.Middleware
I think that wrapping
reqwest
into any existing or custom made middleware crate would be an overkill so I went with a simple macro and some simple wrappers. The macro frees developers from having to remember which and if all counters were registered. Additionally it produces a list of all the methods as& 'static str
which increases the performance a bit, if we for example compare it to the rpc middleware passing non-static&str
.Testing
metrics
uses a singletonRecorder
, which is a bit problematic when trying to test metricsTL;DR:
x
, useRecorderGuard::lock(MyLocalMockRecorderInstance)
x
should useRecorderGuard::lock_as_noop()
x
don't care aboutRecorderGuard
I updated the
RecorderGuard
to decrease contention between tests that do not assert any counters. Unfortunately if one wishes to have repetitive results in a test which does assert some counter values, all other tests that could be triggering those counters concurrently have to useRecorderGuard::lock_as_noop()
.