Skip to content

FFM-11022 Applies standard Metrics Enhancements #112

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

Merged
merged 13 commits into from
Apr 10, 2024
Merged

Conversation

erdirowlands
Copy link
Contributor

What

  • Splits evaluation and target metrics into their own caches:

    • so that we can track target metrics correctly. Due to the fact we use the globalTarget , this meant that we would miss targets if the evaluation didn't change.
    • Implements limits: Evaluation metrics to 10K unique evaluations--where a unique evaluation is flag + variation--this allows for evaluation for 10k flags with 5 variations each
    • Target metrics for 100K unique targets
  • Implement seen targets:

    • ensures that the metrics service only gets sent target metrics for a target once, for the lifetime of the SDK instance
    • ensures that the SDK processes truly unique targets fairly, and that old targets don't occupy the 100K limit set per interval

Testing

  • Metrics accuracy:
    • TestGrid metrics tests
    • Manual sample app
    • Non-anonymous targets appear in UI
    • Anonymous targets don't appear in UI
  • SeenTargets:
    • The same target won't be sent on the next interval if it is evaluated against
  • Limits:
    • Sent 101K unique targets, only 100K get processed

Copy link
Contributor

@knagurski knagurski left a comment

Choose a reason for hiding this comment

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

Just some comments/suggestions to help with maintainability. No blockers

Comment on lines +66 to +67
private MAX_EVALUATION_ANALYTICS_SIZE = 10000;
private MAX_TARGET_ANALYTICS_SIZE = 100000;
Copy link
Contributor

Choose a reason for hiding this comment

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

I THINK you can set these as static. Will make zero difference, but ¯_(ツ)_/¯


clonedEvaluationAnalytics.forEach((event) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

TOTALLY not an issue, but instead of creating a variable and then using a forEach to push to that variable. You can just swap to map and assign in one.

Suggested change
clonedEvaluationAnalytics.forEach((event) => {
const metricsData: MetricsData[] = clonedEvaluationAnalytics.map((event) => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like 🚀 thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dang - the map function isn't available on Map types. I'd need to convert clonedEvaluationAnalytics to an array. I'll opt to leave it as is. But in principle I agree with the functional style here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah man... annoying. You could spread into an array or use Array.from. Don't worry about it, it's fine as-is.

Suggested change
clonedEvaluationAnalytics.forEach((event) => {
const metricsData: MetricsData[] = [...clonedEvaluationAnalytics.values()].map((event) => {

}
});

clonedTargetAnalytics.forEach((target) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Also totally a non-issue.

Suggested change
clonedTargetAnalytics.forEach((target) => {
const targetData: TargetData[] = clonedTargetAnalytics.map((target) => {

src/metrics.ts Outdated
Comment on lines 231 to 236
const td: TargetData = {
identifier: target.identifier,
name: targetName,
attributes: targetAttributes,
};
targetData.push(td);
Copy link
Contributor

Choose a reason for hiding this comment

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

If you do want to keep as a forEach/push, then you might as well just inline this.

Suggested change
const td: TargetData = {
identifier: target.identifier,
name: targetName,
attributes: targetAttributes,
};
targetData.push(td);
targetData.push({
identifier: target.identifier,
name: targetName,
attributes: targetAttributes,
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

erdirowlands and others added 4 commits April 10, 2024 11:38
Co-authored-by: Kevin Nagurski <[email protected]>
Co-authored-by: Kevin Nagurski <[email protected]>
Co-authored-by: Kevin Nagurski <[email protected]>
@erdirowlands erdirowlands merged commit b374566 into main Apr 10, 2024
1 check passed
@erdirowlands erdirowlands deleted the FFM-11022 branch April 10, 2024 11:38
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