Skip to content

Conversation

vazarkevych
Copy link
Collaborator

…eriment and experiment result for tracking callback invocation

Volodymyr Nazarkevych added 2 commits April 3, 2025 16:45
…eriment and experiment result for tracking callback invocation
# Conflicts:
#	lib/src/main/java/growthbook/sdk/java/evaluators/FeatureEvaluator.java

// Add the experiment to the tracker if it doesn't exist.
if (!experimentTracker.isExperimentTracked(key)) {
experimentTracker.trackExperiment(key);
Copy link
Contributor

Choose a reason for hiding this comment

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

We use an Experiment Tracker to keep track of the most recent experiments set with a bounded max val of 30(which can be changed). Changing this implementation to a unbounded hashSet will grow significantly when there are multiple instances of GrowthBookClient is created.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We’ve restored your implementation of the Experiment Tracker as suggested.

@@ -157,6 +157,7 @@ public Options(@Nullable Boolean enabled,
@Nullable
private Map<String, Object> globalForcedFeatureValues;

private ExperimentHelper experimentHelper = new ExperimentHelper();
Copy link
Contributor

Choose a reason for hiding this comment

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

Options is not a place for initializing experimentHelper. Options technically provides all configurable parameters that influence the behavior of GrowthBook instance.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, we have moved the Experiment Tracker to the Global Context. We need this instance to be a singleton in order to track experiments and their results properly — only once. Previously, it was being recreated during every evaluation process

…cker to GlobalContext to make it singleton, remove ExperimentHelper from Options class
@vazarkevych vazarkevych requested a review from madhuchavva May 9, 2025 11:48
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.

2 participants