Skip to content

Commit 488b477

Browse files
committed
Address final feature flagging review feedback
1 parent c146f09 commit 488b477

5 files changed

Lines changed: 31 additions & 4 deletions

File tree

internal-api/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ dependencies {
268268
api(project(":components:context"))
269269
api(project(":components:environment"))
270270
api(project(":components:json"))
271-
api(project(":products:feature-flagging:feature-flagging-config"))
271+
implementation(project(":products:feature-flagging:feature-flagging-config"))
272272
api(project(":utils:config-utils"))
273273
api(project(":utils:time-utils"))
274274

internal-api/src/main/java/datadog/trace/api/Config.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3802,7 +3802,21 @@ private static String normalizeFeatureFlaggingConfigurationSource(final String s
38023802
return DEFAULT_FEATURE_FLAGGING_CONFIGURATION_SOURCE;
38033803
}
38043804
final String normalized = source.trim().toLowerCase(Locale.ROOT);
3805-
return normalized.isEmpty() ? DEFAULT_FEATURE_FLAGGING_CONFIGURATION_SOURCE : normalized;
3805+
if (normalized.isEmpty()) {
3806+
return DEFAULT_FEATURE_FLAGGING_CONFIGURATION_SOURCE;
3807+
}
3808+
switch (normalized) {
3809+
case "agentless":
3810+
case "remote_config":
3811+
case "offline":
3812+
return normalized;
3813+
default:
3814+
log.warn(
3815+
"Unsupported Feature Flagging configuration source: {}. Defaulting to {}",
3816+
source,
3817+
DEFAULT_FEATURE_FLAGGING_CONFIGURATION_SOURCE);
3818+
return DEFAULT_FEATURE_FLAGGING_CONFIGURATION_SOURCE;
3819+
}
38063820
}
38073821

38083822
public boolean isBaggageExtract() {

internal-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3517,6 +3517,7 @@ class ConfigTest extends DDSpecification {
35173517
"" | "agentless"
35183518
" " | "agentless"
35193519
" ReMoTe_ConFiG " | "remote_config"
3520+
"not-a-real-source" | "agentless"
35203521
}
35213522
35223523
def "agentless feature flag timing falls back for non-positive values"() {

products/feature-flagging/feature-flagging-agent/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dependencies {
2020

2121
testImplementation(libs.bundles.junit5)
2222
testImplementation(libs.bundles.mockito)
23+
testImplementation(project(":products:feature-flagging:feature-flagging-config"))
2324
testImplementation(project(":utils:test-utils"))
2425
testRuntimeOnly(project(":dd-trace-core"))
2526
}

products/feature-flagging/feature-flagging-agent/src/test/java/com/datadog/featureflag/FeatureFlaggingSystemTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,23 @@ void explicitRemoteConfigUsesRemoteConfigService() {
9797

9898
@Test
9999
@WithConfig(key = FEATURE_FLAGS_CONFIGURATION_SOURCE, value = "invalid")
100-
void invalidConfigurationSourceFailsBeforeStartingNetworkSource() {
100+
void invalidConfigurationSourceUsesAgentlessDefault() {
101+
assertInstanceOf(
102+
AgentlessConfigurationSource.class,
103+
FeatureFlaggingSystem.createConfigurationSourceService(
104+
sharedCommunicationObjects(), Config.get()));
105+
}
106+
107+
@Test
108+
void rejectsUnsupportedNormalizedConfigurationSource() {
109+
Config config = mock(Config.class);
110+
when(config.getFeatureFlaggingConfigurationSource()).thenReturn("invalid");
111+
101112
assertThrows(
102113
IllegalArgumentException.class,
103114
() ->
104115
FeatureFlaggingSystem.createConfigurationSourceService(
105-
sharedCommunicationObjects(), Config.get()));
116+
sharedCommunicationObjects(), config));
106117
}
107118

108119
@Test

0 commit comments

Comments
 (0)