Skip to content
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

chore: more granular metrics for routes/quotes fetched #756

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/routers/alpha-router/quoters/mixed-quoter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ export class MixedQuoter extends BaseQuoter<
MetricLoggerUnit.Milliseconds
);

metric.putMetric(
`MixedQuotesLoad_Chain_${this.chainId}`,
Date.now() - beforeQuotes
);

metric.putMetric(
'MixedQuotesFetched',
_(routesWithQuotes)
Expand All @@ -249,6 +254,20 @@ export class MixedQuoter extends BaseQuoter<
MetricLoggerUnit.Count
);

metric.putMetric(
`MixedQuotesFetched_Chain_${this.chainId}`,
_(routesWithQuotes)
.map(([, quotes]) => quotes.length)
.sum()
);

metric.putMetric(`MixedRoutesFetched`, _(routesWithQuotes).sum());

metric.putMetric(
`MixedRoutesFetched_Chain_${this.chainId}`,
_(routesWithQuotes).sum()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

number of routes with quotes should just be routesWithQuotes.length?

);

const routesWithValidQuotes = [];

for (const routeWithQuote of routesWithQuotes) {
Expand Down
19 changes: 19 additions & 0 deletions src/routers/alpha-router/quoters/v2-quoter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ export class V2Quoter extends BaseQuoter<V2CandidatePools, V2Route, Token> {
MetricLoggerUnit.Milliseconds
);

metric.putMetric(
`V2QuotesLoad_Chain_${this.chainId}`,
Date.now() - beforeQuotes
);

metric.putMetric(
'V2QuotesFetched',
_(routesWithQuotes)
Expand All @@ -213,6 +218,20 @@ export class V2Quoter extends BaseQuoter<V2CandidatePools, V2Route, Token> {
MetricLoggerUnit.Count
);

metric.putMetric(
`V2QuotesFetched_Chain_${this.chainId}`,
_(routesWithQuotes)
.map(([, quotes]) => quotes.length)
.sum()
);

metric.putMetric(`V2RoutesFetched`, _(routesWithQuotes).sum());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this logs the routes fetched in case we have a cache routes miss. in case we have a cached routes hit, it will be within refreshRoutesThenGetQuotes.

I'm thinking (1) whether we should log routes and/or quotes fetched in case of cached routes hit (2) whether we should log both cached routes hit and cached routes miss

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense - lets chat


metric.putMetric(
`V2RoutesFetched_Chain_${this.chainId}`,
_(routesWithQuotes).sum()
);

const routesWithValidQuotes = [];

for (const routeWithQuote of routesWithQuotes) {
Expand Down
19 changes: 19 additions & 0 deletions src/routers/alpha-router/quoters/v3-quoter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ export class V3Quoter extends BaseQuoter<V3CandidatePools, V3Route, Token> {
MetricLoggerUnit.Milliseconds
);

metric.putMetric(
`V3QuotesLoad_Chain_${this.chainId}`,
Date.now() - beforeQuotes
);

metric.putMetric(
'V3QuotesFetched',
_(routesWithQuotes)
Expand All @@ -182,6 +187,20 @@ export class V3Quoter extends BaseQuoter<V3CandidatePools, V3Route, Token> {
MetricLoggerUnit.Count
);

metric.putMetric(
`V3QuotesFetched_Chain_${this.chainId}`,
_(routesWithQuotes)
.map(([, quotes]) => quotes.length)
.sum()
);

metric.putMetric(`V3RoutesFetched`, _(routesWithQuotes).sum());

metric.putMetric(
`V3RoutesFetched_Chain_${this.chainId}`,
_(routesWithQuotes).sum()
);

const routesWithValidQuotes = [];

for (const routeWithQuote of routesWithQuotes) {
Expand Down
19 changes: 19 additions & 0 deletions src/routers/alpha-router/quoters/v4-quoter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ export class V4Quoter extends BaseQuoter<V4CandidatePools, V4Route, Currency> {
MetricLoggerUnit.Milliseconds
);

metric.putMetric(
`V4QuotesLoad_Chain_${this.chainId}`,
Date.now() - beforeQuotes
);

metric.putMetric(
'V4QuotesFetched',
_(routesWithQuotes)
Expand All @@ -181,6 +186,20 @@ export class V4Quoter extends BaseQuoter<V4CandidatePools, V4Route, Currency> {
MetricLoggerUnit.Count
);

metric.putMetric(
`V4QuotesFetched_Chain_${this.chainId}`,
_(routesWithQuotes)
.map(([, quotes]) => quotes.length)
.sum()
);

metric.putMetric(`V4RoutesFetched`, _(routesWithQuotes).sum());

metric.putMetric(
`V4RoutesFetched_Chain_${this.chainId}`,
_(routesWithQuotes).sum()
);

const routesWithValidQuotes = [];

for (const routeWithQuote of routesWithQuotes) {
Expand Down
Loading