feat(assets-controllers): token price service degraded metrics #3691
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.
Explanation
The option
onDegraded
has been added to theCodefiTokenPricesServiceV2
service, which lets us react to situations where the service is still presumed to be available (i.e. there is no outage, the circuit has not broken) but a request failed, or succeeded too slowly. We can use this option to track instances of degraded service in production.The option
degradedThreshold
has also been added. This acts as a definition of "degraded service"; if requests are slower than this duration, we consider the service to be degraded.References
Closes #3689
Changelog
@metamask/assets-controllers
CodefiTokenPricesServiceV2
for tracking degraded serviceonDegraded
anddegradedThreshold
.onDegraded
is an event handler for instances of degraded service (i.e. failed or slow requests), anddegradedThreshold
determines how slow a request has to be before we consider service to be degraded.Checklist