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

feat(cardinality): Implement cardinality reporting #3342

Merged
merged 5 commits into from Mar 28, 2024

Conversation

Dav1dde
Copy link
Member

@Dav1dde Dav1dde commented Mar 26, 2024

Makes the cardinality limiter able to report cardinality per "sub"-scope and return the collected information.

Cardinality Limits can now opt-in into recording/reporting cardinality per limit/generated scope. The reports will be accumulated and exposed through the CardinalityResult.

The collected reports are not yet used in Relay, it's a preparation to use the reports in a followup:

// Somewhere post cardinality limiter in the processor:
for (limit, report) in r.cardinality_reports() {
    self.metric_stats.track_cardinality(limit, report);
}

#skip-changelog

@Dav1dde Dav1dde mentioned this pull request Mar 26, 2024
@Dav1dde Dav1dde self-assigned this Mar 26, 2024
Base automatically changed from dav1d/ref/pipeline-card to master March 28, 2024 10:10
@Dav1dde Dav1dde force-pushed the dav1d/ref/card-reports branch 2 times, most recently from d7e8de0 to 0bcb7ff Compare March 28, 2024 10:19
@Dav1dde Dav1dde marked this pull request as ready for review March 28, 2024 10:20
@Dav1dde Dav1dde requested a review from a team as a code owner March 28, 2024 10:20
Copy link
Member

@iker-barriocanal iker-barriocanal left a comment

Choose a reason for hiding this comment

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

Thanks for updating the docs!

relay-cardinality/src/limiter.rs Show resolved Hide resolved
Comment on lines +54 to +55
/// The callback can be called multiple times with different reports
/// for the same `limit` or not at all if there was no change in cardinality.
Copy link
Member

Choose a reason for hiding this comment

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

there was no change in cardinality.

What does that mean? Is this function called only when going to redis and not when using a cache?

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly! Which comes down to, it is valid to only call the callback when the actual cardinality in the window increased.

relay-cardinality/src/limiter.rs Outdated Show resolved Hide resolved
relay-cardinality/src/redis/quota.rs Show resolved Hide resolved
Comment on lines 217 to 218
limits: HashSet<&'a CardinalityLimit>,
reports: BTreeMap<&'a CardinalityLimit, Vec<CardinalityReport>>,
Copy link
Member

Choose a reason for hiding this comment

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

Could this be a single map instead of a hash set and a btreemap, with an empty Vec if limit.report is false?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just implemented it, but I it's actually wrong. There can be cardinality reports for limits which have not been exceeded.

I'll revert and rename the field to make it more clear!

relay-cardinality/src/limiter.rs Show resolved Hide resolved
@Dav1dde Dav1dde enabled auto-merge (squash) March 28, 2024 14:27
@Dav1dde Dav1dde merged commit 3bd0266 into master Mar 28, 2024
20 checks passed
@Dav1dde Dav1dde deleted the dav1d/ref/card-reports branch March 28, 2024 14:47
jan-auer added a commit that referenced this pull request Apr 3, 2024
* master:
  feat(metric-stats): Report cardinality to metric stats (#3360)
  release: 0.8.56
  fix(perfscore): Adds span op tag to perf score totals (#3326)
  ref(profiles): Return retention_days as part of the Kafka message (#3362)
  ref(filter): Add GTmetrix to the list of web crawlers (#3363)
  fix: Fix kafka topic default (#3350)
  ref(normalization): Remove duplicated normalization (#3355)
  feat(feedback): Emit outcomes for user feedback events (#3026)
  feat(cardinality): Implement cardinality reporting (#3342)
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.

None yet

3 participants