-
Notifications
You must be signed in to change notification settings - Fork 319
Implementation of the open feature SDK in the java tracer #9885
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
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1514e4d
Initial implementation of the OpenFeature SDK
manuel-alvarez-alvarez c149316
Fix class name
manuel-alvarez-alvarez e4ce84d
Change in modularization
manuel-alvarez-alvarez f8d2c02
Fix tests
manuel-alvarez-alvarez 37a69be
Fix package name
manuel-alvarez-alvarez 1c5b259
Fix CODEOWNERS
manuel-alvarez-alvarez 853fb98
Remove shadow jar
manuel-alvarez-alvarez 805f42d
Remove equals
manuel-alvarez-alvarez 77bcb52
Add unit
manuel-alvarez-alvarez c698e49
Improve date handling
manuel-alvarez-alvarez 81699d6
Remove common classes from internal-api
manuel-alvarez-alvarez 8e8781e
Add factory method for errors
manuel-alvarez-alvarez b807173
Configure maven publishing for the SDK
manuel-alvarez-alvarez ead21d2
Update codeowners
manuel-alvarez-alvarez 8a44b11
Remove log4j dependency from API
manuel-alvarez-alvarez 45177ee
Fix coverage
manuel-alvarez-alvarez 31a1f96
Fix class name
manuel-alvarez-alvarez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
dd-trace-api/src/main/java/datadog/trace/api/config/FeatureFlaggingConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package datadog.trace.api.config; | ||
|
|
||
| public class FeatureFlaggingConfig { | ||
|
|
||
| public static final String FLAGGING_PROVIDER_ENABLED = "experimental.flagging.provider.enabled"; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
| import org.gradle.kotlin.dsl.project | ||
|
|
||
| plugins { | ||
| `java-library` | ||
| id("com.gradleup.shadow") | ||
| } | ||
|
|
||
| apply(from = "$rootDir/gradle/java.gradle") | ||
| apply(from = "$rootDir/gradle/version.gradle") | ||
|
|
||
| description = "Feature flagging agent system" | ||
|
|
||
| dependencies { | ||
| api(libs.slf4j) | ||
| api(project(":products:feature-flagging:lib")) | ||
| api(project(":internal-api")) | ||
|
|
||
| testImplementation(project(":utils:test-utils")) | ||
| testRuntimeOnly(project(":dd-trace-core")) | ||
| } | ||
|
|
||
| tasks.named<ShadowJar>("shadowJar") { | ||
| dependencies { | ||
| val deps = project.extra["deps"] as Map<*, *> | ||
| val excludeShared = deps["excludeShared"] as groovy.lang.Closure<*> | ||
| excludeShared.delegate = this | ||
| excludeShared.call() | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
...s/feature-flagging/agent/src/main/java/com/datadog/featureflag/FeatureFlaggingSystem.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package com.datadog.featureflag; | ||
|
|
||
| import datadog.communication.ddagent.SharedCommunicationObjects; | ||
| import datadog.trace.api.Config; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class FeatureFlaggingSystem { | ||
|
|
||
| private static final Logger LOGGER = LoggerFactory.getLogger(FeatureFlaggingSystem.class); | ||
|
|
||
| private static volatile RemoteConfigService CONFIG_SERVICE; | ||
| private static volatile ExposureWriter EXPOSURE_WRITER; | ||
|
|
||
| private FeatureFlaggingSystem() {} | ||
|
|
||
| public static void start(final SharedCommunicationObjects sco) { | ||
| LOGGER.debug("Feature Flagging system starting"); | ||
| final Config config = Config.get(); | ||
|
|
||
| if (!config.isRemoteConfigEnabled()) { | ||
| throw new IllegalStateException("Feature Flagging system started without RC"); | ||
| } | ||
| CONFIG_SERVICE = new RemoteConfigServiceImpl(sco, config); | ||
| CONFIG_SERVICE.init(); | ||
|
|
||
| EXPOSURE_WRITER = new ExposureWriterImpl(sco, config); | ||
| EXPOSURE_WRITER.init(); | ||
|
|
||
| LOGGER.debug("Feature Flagging system started"); | ||
| } | ||
|
|
||
| public static void stop() { | ||
| if (EXPOSURE_WRITER != null) { | ||
| EXPOSURE_WRITER.close(); | ||
| EXPOSURE_WRITER = null; | ||
| } | ||
| if (CONFIG_SERVICE != null) { | ||
| CONFIG_SERVICE.close(); | ||
| CONFIG_SERVICE = null; | ||
| } | ||
| LOGGER.debug("Feature Flagging system stopped"); | ||
| } | ||
| } |
60 changes: 60 additions & 0 deletions
60
...e-flagging/agent/src/test/groovy/com/datadog/featureflag/FeatureFlaggingSystemTest.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package com.datadog.featureflag | ||
|
|
||
| import datadog.communication.ddagent.DDAgentFeaturesDiscovery | ||
| import datadog.communication.ddagent.SharedCommunicationObjects | ||
| import datadog.remoteconfig.Capabilities | ||
| import datadog.remoteconfig.ConfigurationDeserializer | ||
| import datadog.remoteconfig.ConfigurationPoller | ||
| import datadog.remoteconfig.Product | ||
| import datadog.trace.api.Config | ||
| import datadog.trace.test.util.DDSpecification | ||
| import okhttp3.HttpUrl | ||
|
|
||
| class FeatureFlaggingSystemTest extends DDSpecification { | ||
|
|
||
| void 'test feature flag system initialization'() { | ||
| setup: | ||
| final poller = Mock(ConfigurationPoller) | ||
| final discovery = Stub(DDAgentFeaturesDiscovery) { | ||
| discoverIfOutdated() >> {} | ||
| supportsEvpProxy() >> { return true } | ||
| } | ||
| final sco = Stub(SharedCommunicationObjects) { | ||
| configurationPoller(_ as Config) >> poller | ||
| featuresDiscovery(_ as Config) >> discovery | ||
| } | ||
| sco.featuresDiscovery = discovery | ||
| sco.agentUrl = HttpUrl.get('http://localhost') | ||
|
|
||
| when: | ||
| FeatureFlaggingSystem.start(sco) | ||
|
|
||
| then: | ||
| 1 * poller.addCapabilities(Capabilities.CAPABILITY_FFE_FLAG_CONFIGURATION_RULES) | ||
| 1 * poller.addListener(Product.FFE_FLAGS, _ as ConfigurationDeserializer, _) | ||
| 1 * poller.start() | ||
|
|
||
| when: | ||
| FeatureFlaggingSystem.stop() | ||
|
|
||
| then: | ||
| 1 * poller.removeCapabilities(Capabilities.CAPABILITY_FFE_FLAG_CONFIGURATION_RULES) | ||
| 1 * poller.removeListeners(Product.FFE_FLAGS) | ||
| 1 * poller.stop() | ||
| } | ||
|
|
||
| void 'test that remote config is required'() { | ||
| setup: | ||
| injectSysConfig('remote_configuration.enabled', 'false') | ||
| final sco = Mock(SharedCommunicationObjects) | ||
|
|
||
| when: | ||
| FeatureFlaggingSystem.start(sco) | ||
|
|
||
| then: | ||
| thrown(IllegalStateException) | ||
|
|
||
| cleanup: | ||
| FeatureFlaggingSystem.stop() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis | ||
| import groovy.lang.Closure | ||
|
|
||
| plugins { | ||
| `java-library` | ||
| idea | ||
| `maven-publish` | ||
| } | ||
|
|
||
| apply(from = "$rootDir/gradle/java.gradle") | ||
| apply(from = "$rootDir/gradle/publish.gradle") | ||
|
|
||
| val minJavaVersionForTests by extra(JavaVersion.VERSION_11) | ||
|
|
||
| description = "Implementation of the OpenFeature Provider interface." | ||
|
|
||
| // Set both JAR and Maven artifact name | ||
| val openFeatureArtifactId = "dd-openfeature" | ||
| base { | ||
| archivesName.set(openFeatureArtifactId) | ||
| } | ||
|
|
||
| publishing { | ||
| publications.withType<MavenPublication>().configureEach { | ||
| artifactId = openFeatureArtifactId | ||
| } | ||
| } | ||
|
|
||
| idea { | ||
| module { | ||
| jdkName = "11" | ||
| } | ||
| } | ||
|
|
||
| java { | ||
| toolchain { | ||
| languageVersion = JavaLanguageVersion.of(11) | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| api("dev.openfeature:sdk:1.18.2") | ||
|
|
||
| compileOnly(project(":products:feature-flagging:bootstrap")) | ||
|
|
||
| testImplementation(project(":products:feature-flagging:bootstrap")) | ||
| testImplementation(libs.bundles.junit5) | ||
| testImplementation(libs.bundles.mockito) | ||
| testImplementation(libs.moshi) | ||
| testImplementation("org.awaitility:awaitility:4.3.0") | ||
| } | ||
|
|
||
| fun AbstractCompile.configureCompiler( | ||
| javaVersionInteger: Int, | ||
| compatibilityVersion: JavaVersion? = null, | ||
| unsetReleaseFlagReason: String? = null | ||
| ) { | ||
| (project.extra["configureCompiler"] as Closure<*>).call( | ||
| this, | ||
| javaVersionInteger, | ||
| compatibilityVersion, | ||
| unsetReleaseFlagReason | ||
| ) | ||
| } | ||
|
|
||
| tasks.withType<JavaCompile>().configureEach { | ||
| configureCompiler(11, JavaVersion.VERSION_11) | ||
| } | ||
|
|
||
| tasks.withType<Javadoc>().configureEach { | ||
| javadocTool = javaToolchains.javadocToolFor(java.toolchain) | ||
| } | ||
|
|
||
| tasks.named<CheckForbiddenApis>("forbiddenApisMain") { | ||
| failOnMissingClasses = false | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.