Skip to content

fix(quotas): Correct reporting of rate limits for transactions - #1555

Merged
jan-auer merged 2 commits into
masterfrom
fix/tx-rate-limit-outcomes
Oct 27, 2022
Merged

jan-auer merged 2 commits into
masterfrom
fix/tx-rate-limit-outcomes

Conversation

@jan-auer

Copy link
Copy Markdown
Member

With #1537 Relay started to under-report outcomes for rate limited transactions.
The root cause is that Enforcement was not updated to emit outcomes for
metrics.

This reveals that enforcements for metrics should be recorded only if metrics
have not been extracted from a transaction item yet. In this case, metrics can
still be considered part of the transaction item and as such an outcome is
needed. In contrast, once metrics have been extracted, responsibility for
recording outcomes is moved to the recipient of metrics.

@jan-auer
jan-auer requested a review from a team October 27, 2022 15:38
});

if enforcement.event_metrics_active() {
state.extracted_metrics.clear();

@jan-auer jan-auer Oct 27, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was introduced in #1537, but it is now dead code. Metrics will always be extracted at this point, and as such event_metrics_active can never be true.

This is not a problem, since the extracted metrics will be sent to the project cache and be dropped there. Over there, we have proper outcome logging for metrics implemented. It's an unnecessary indirection, but is the smallest change to get this consistent and working.

@iker-barriocanal iker-barriocanal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚀


assert!(limits.is_limited());
assert!(enforcement.event_metrics.is_active());
assert!(!enforcement.event_metrics.is_active());

@jan-auer jan-auer Oct 27, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This change is intentional. We don't want an enforcement -- and not record outcomes -- if metrics had been extracted already. The outcome would be logged somewhere else.

@olksdr olksdr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

@jan-auer
jan-auer enabled auto-merge (squash) October 27, 2022 15:53
@jan-auer
jan-auer merged commit 80a6dd9 into master Oct 27, 2022
@jan-auer
jan-auer deleted the fix/tx-rate-limit-outcomes branch October 27, 2022 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants