-
Notifications
You must be signed in to change notification settings - Fork 117
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
[CORE-354] - Add tracking for market availability in order to alert in datadog #706
Conversation
CORE-354 monitor unavailable symbols from exchanges
once this is done, we can reduce sensitivity of see thread |
WalkthroughThe changes introduce telemetry tracking for market availability on exchanges in the price fetcher daemon. A new function Changes
TipsChat with CodeRabbit Bot (
|
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 (2)
- protocol/daemons/pricefeed/client/price_fetcher/price_fetcher.go (4 hunks)
- protocol/lib/metrics/constants.go (1 hunks)
Files skipped from review due to trivial changes (2)
- protocol/daemons/pricefeed/client/price_fetcher/price_fetcher.go
- protocol/lib/metrics/constants.go
protocol/daemons/pricefeed/client/price_fetcher/price_fetcher.go
Outdated
Show resolved
Hide resolved
pf.writeToBufferedChannel(exchangeId, price, err) | ||
} | ||
|
||
// Emit metrics on this exchange's market availability. | ||
for marketId, available := range availableMarkets { |
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.
For my understanding what is the cadence of this logic? Is it per runSubTask
run? How often is it?
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.
It's run once every time a price fetcher makes a query.
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 (1)
- protocol/daemons/pricefeed/client/price_fetcher/price_fetcher.go (4} hunks)
Additional comments: 4
protocol/daemons/pricefeed/client/price_fetcher/price_fetcher.go (4)
- 3-9: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [6-10]
The import of the
telemetry
package is new. Ensure that this package is installed and available in the project dependencies.
187-206: The
emitMarketAvailabilityMetrics
function is a new addition. It emits telemetry data about the availability of a market on an exchange. The function takes an exchange ID, market ID, and a boolean indicating availability as parameters. It uses thetelemetry.IncrCounterWithLabels
function to increment a counter with specific labels. This function seems to be well-structured and follows good practices.264-277: The code now emits telemetry data when a query fails. It iterates over all market IDs and calls
emitMarketAvailabilityMetrics
withfalse
for availability. This is a good practice as it provides visibility into market availability during failures. However, ensure that theemitMarketAvailabilityMetrics
function handles errors properly and does not cause therunSubTask
function to fail.306-315: The code now tracks which markets were available when queried. It uses a map to store the availability of each market and emits telemetry data for each market. This is a good practice as it provides visibility into market availability. However, ensure that the
emitMarketAvailabilityMetrics
function handles errors properly and does not cause therunSubTask
function to fail.
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 (2)
- protocol/daemons/pricefeed/client/price_fetcher/price_fetcher.go (4} hunks)
- protocol/lib/metrics/constants.go (2} hunks)
Files skipped from review due to trivial changes (1)
- protocol/lib/metrics/constants.go
Additional comments: 4
protocol/daemons/pricefeed/client/price_fetcher/price_fetcher.go (4)
6-8: The new imports
github.com/cosmos/cosmos-sdk/telemetry
andmath/rand
are introduced to support telemetry metrics and random sampling respectively. Ensure that these packages are used appropriately in the code.188-207: The new function
emitMarketAvailabilityMetrics
is introduced to emit telemetry metrics that track the availability of a market when queried on an exchange. The function takes inexchangeId
,id
(marketId), andavailable
as parameters. It uses thetelemetry.IncrCounterWithLabels
function from thecosmos-sdk/telemetry
package to increment a counter with labels. The labels include thePricefeedDaemon
,PriceFetcherQueryForMarket
, andsuccess
(which can be eithermetrics.Success
ormetrics.Error
depending on theavailable
parameter). The function seems to be well-structured and logically sound.263-284: The
runSubTask
function is updated to include telemetry metrics. If an error occurs during the price fetching process, the function will report all markets as unavailable. It also creates a mapavailableMarkets
to track which markets were available when queried. Ensure that these changes do not affect the overall functionality of therunSubTask
function.312-323: The
runSubTask
function is further updated to mark a market as available in theavailableMarkets
map if a price is successfully fetched for it. It also emits metrics on the exchange's market availability according to the sampling rate. These changes seem to be logically sound and should improve the system's ability to monitor and alert on market availability issues.
telemetry.IncrCounterWithLabels( | ||
[]string{ | ||
metrics.PricefeedDaemon, | ||
metrics.PriceFetcherQueryForMarket, |
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.
Nit: perhaps update the metrics name with a suffix like _sampled
so it's clear that this is a sampled metric
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 (1)
- protocol/lib/metrics/constants.go (2} hunks)
Files skipped from review due to trivial changes (1)
- protocol/lib/metrics/constants.go
…n datadog (#706) (#712) Co-authored-by: Crystal Lemire <[email protected]>
Changelist
Track availability of market symbols in each exchange for alerting purposes.
Test Plan
Existing tests, this is a telemetry change.
Author/Reviewer Checklist
state-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.