Skip to content

feat(cardinality): Implement cardinality reporting#3342

Merged
Dav1dde merged 5 commits intomasterfrom
dav1d/ref/card-reports
Mar 28, 2024
Merged

feat(cardinality): Implement cardinality reporting#3342
Dav1dde merged 5 commits intomasterfrom
dav1d/ref/card-reports

Conversation

@Dav1dde
Copy link
Copy Markdown
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
@Dav1dde Dav1dde force-pushed the dav1d/ref/pipeline-card branch from 77ad55b to 021cd65 Compare March 28, 2024 09:48
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
@Dav1dde Dav1dde force-pushed the dav1d/ref/card-reports branch from 0bcb7ff to 8a8f404 Compare March 28, 2024 10:24
Copy link
Copy Markdown
Contributor

@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!

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
Copy Markdown
Contributor

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
Copy Markdown
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.

Comment on lines 217 to +218
limits: HashSet<&'a CardinalityLimit>,
reports: BTreeMap<&'a CardinalityLimit, Vec<CardinalityReport>>,
Copy link
Copy Markdown
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
Copy Markdown
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!

@Dav1dde Dav1dde force-pushed the dav1d/ref/card-reports branch from 859cfdb to 0473d8c Compare March 28, 2024 14:19
@Dav1dde Dav1dde enabled auto-merge (squash) March 28, 2024 14:27
@Dav1dde Dav1dde merged commit 3bd0266 into master Mar 28, 2024
@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.

3 participants