Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ClientFeatureRepository extends AbstractFeatureRepository
private ObjectMapper jsonConfigObjectMapper;
private final ApplyFeature applyFeature;
private boolean serverEvaluation = false; // the client tells us, we pass it out to others
private boolean logErrorIfKeyNotDefined = true; // log message with level ERROR if key is not defined

private final TypeReference<List<io.featurehub.sse.model.FeatureState>> FEATURE_LIST_TYPEDEF =
new TypeReference<List<io.featurehub.sse.model.FeatureState>>() {};
Expand All @@ -56,6 +57,11 @@ public ClientFeatureRepository(int threadPoolSize) {
this(getExecutor(threadPoolSize), null);
}

public ClientFeatureRepository(int threadPoolSize, boolean logErrorIfKeyNotDefined) {
this(threadPoolSize);
this.logErrorIfKeyNotDefined = logErrorIfKeyNotDefined;
}

public ClientFeatureRepository() {
this(1);
}
Expand Down Expand Up @@ -248,13 +254,11 @@ public FeatureState getFeatureState(String key) {
return features.computeIfAbsent(
key,
key1 -> {
if (hasReceivedInitialState) {
log.error(
"FeatureHub error: application requesting use of invalid key after initialization: `{}`",
key1);
if (hasReceivedInitialState && logErrorIfKeyNotDefined) {
log.error("FeatureHub error: application is requesting to use not defined key after initialization: `{}`", key1);
}

return new FeatureStateBase(null, this, key);
return new FeatureStateBase(null, this, key1);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class FeatureHubSource implements FeatureHub {
String analyticsCid = "";
@ConfigKey("feature-service.sdk")
String clientSdk = "jersey3";
@ConfigKey("feature-service.logs.error-if-key-not-defined")
boolean logErrorIfKeyNotDefined = true;

private final FeatureRepositoryContext repository;
private final EdgeFeatureHubConfig config;
Expand All @@ -39,7 +41,7 @@ public FeatureHubSource() {

config = new EdgeFeatureHubConfig(featureHubUrl, sdkKey);

repository = new ClientFeatureRepository(5);
repository = new ClientFeatureRepository(5, logErrorIfKeyNotDefined);
repository.registerValueInterceptor(true, new SystemPropertyValueInterceptor());

if (analyticsCid.length() > 0 && analyticsKey.length() > 0) {
Expand Down