Skip to content

Commit e00532b

Browse files
PerfectSlayerclaude
andcommitted
feat(ffe): Connect the dd-openfeature SDK to the agent
Ship the standalone dd-openfeature SDK in place of the agent-coupled provider. The new dd-openfeature-connector instrumentation detects the SDK and plugs the agent backend in through the FeatureFlaggingGateway: Remote Configuration documents, the event platform proxy, telemetry health metrics and span enrichment. The agent now forwards raw configuration documents and event payloads, UFC parsing, evaluation and event batching stay in the SDK. Remove the feature-flagging-api module and the agent-side agentless configuration and event code the SDK now owns. Keep datadog.trace.api.openfeature.Provider as a deprecated alias. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 27d4862 commit e00532b

131 files changed

Lines changed: 1736 additions & 17230 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/CODEOWNERS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@
343343
/dd-openfeature/ @DataDog/feature-flagging-and-experimentation-sdk
344344
/dd-smoke-tests/openfeature/ @DataDog/feature-flagging-and-experimentation-sdk
345345
/products/feature-flagging/ @DataDog/feature-flagging-and-experimentation-sdk
346+
/dd-java-agent/instrumentation/datadog/openfeature/ @DataDog/feature-flagging-and-experimentation-sdk
346347

347348
# @DataDog/profiling-java
348349
/dd-java-agent/ddprof-lib/ @DataDog/profiling-java

‎.github/workflows/run-system-tests.yaml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ jobs:
4949
JAVA_11_HOME=$JAVA_HOME_11_X64 \
5050
JAVA_17_HOME=$JAVA_HOME_17_X64 \
5151
JAVA_21_HOME=$JAVA_HOME_21_X64 \
52-
./gradlew clean :dd-java-agent:shadowJar \
52+
./gradlew clean :dd-java-agent:shadowJar :dd-openfeature:jar \
5353
--build-cache --parallel --stacktrace --no-daemon --max-workers=4
54+
# System tests install a dd-openfeature jar found next to the agent instead of the published one,
55+
# as the agent supports only the dd-openfeature version built along with it.
56+
cp workspace/dd-openfeature/build/libs/dd-openfeature-*.jar workspace/dd-java-agent/build/libs/
5457
5558
- name: Upload artifact
5659
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a

‎.gitlab-ci.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ build:
355355
script:
356356
- if [ $CI_PIPELINE_SOURCE == "schedule" ] ; then ./gradlew resolveAndLockAll --write-locks $GRADLE_ARGS; fi
357357
- ./gradlew --version
358-
- ./gradlew clean :dd-java-agent:shadowJar :dd-java-agent:check :dd-trace-api:jar :dd-trace-ot:shadowJar :products:feature-flagging:feature-flagging-api:jar -PskipTests -x spotlessCheck $GRADLE_ARGS
358+
- ./gradlew clean :dd-java-agent:shadowJar :dd-java-agent:check :dd-trace-api:jar :dd-trace-ot:shadowJar :dd-openfeature:jar -PskipTests -x spotlessCheck $GRADLE_ARGS
359359
- echo UPSTREAM_TRACER_VERSION=$(java -jar workspace/dd-java-agent/build/libs/*.jar) >> upstream.env
360360
- echo "BUILD_JOB_NAME=$CI_JOB_NAME" >> build.env
361361
- echo "BUILD_JOB_ID=$CI_JOB_ID" >> build.env
@@ -365,7 +365,7 @@ build:
365365
- 'workspace/dd-java-agent/build/libs/*.jar'
366366
- 'workspace/dd-trace-api/build/libs/*.jar'
367367
- 'workspace/dd-trace-ot/build/libs/*.jar'
368-
- 'workspace/products/feature-flagging/feature-flagging-api/build/libs/*.jar'
368+
- 'workspace/dd-openfeature/build/libs/*.jar'
369369
- 'upstream.env'
370370
- '.gradle/daemon/*/*.out.log'
371371
reports:
@@ -482,11 +482,11 @@ publish-artifacts-to-s3:
482482
- aws s3 cp workspace/dd-java-agent/build/libs/dd-java-agent-${VERSION}.jar s3://dd-trace-java-builds/${CI_COMMIT_REF_NAME}/dd-java-agent.jar
483483
- aws s3 cp workspace/dd-trace-api/build/libs/dd-trace-api-${VERSION}.jar s3://dd-trace-java-builds/${CI_COMMIT_REF_NAME}/dd-trace-api.jar
484484
- aws s3 cp workspace/dd-trace-ot/build/libs/dd-trace-ot-${VERSION}.jar s3://dd-trace-java-builds/${CI_COMMIT_REF_NAME}/dd-trace-ot.jar
485-
- aws s3 cp workspace/products/feature-flagging/feature-flagging-api/build/libs/dd-openfeature-${VERSION}.jar s3://dd-trace-java-builds/${CI_COMMIT_REF_NAME}/dd-openfeature.jar
485+
- aws s3 cp workspace/dd-openfeature/build/libs/dd-openfeature-${VERSION}.jar s3://dd-trace-java-builds/${CI_COMMIT_REF_NAME}/dd-openfeature.jar
486486
- aws s3 cp workspace/dd-java-agent/build/libs/dd-java-agent-${VERSION}.jar s3://dd-trace-java-builds/${CI_PIPELINE_ID}/dd-java-agent.jar
487487
- aws s3 cp workspace/dd-trace-api/build/libs/dd-trace-api-${VERSION}.jar s3://dd-trace-java-builds/${CI_PIPELINE_ID}/dd-trace-api.jar
488488
- aws s3 cp workspace/dd-trace-ot/build/libs/dd-trace-ot-${VERSION}.jar s3://dd-trace-java-builds/${CI_PIPELINE_ID}/dd-trace-ot.jar
489-
- aws s3 cp workspace/products/feature-flagging/feature-flagging-api/build/libs/dd-openfeature-${VERSION}.jar s3://dd-trace-java-builds/${CI_PIPELINE_ID}/dd-openfeature.jar
489+
- aws s3 cp workspace/dd-openfeature/build/libs/dd-openfeature-${VERSION}.jar s3://dd-trace-java-builds/${CI_PIPELINE_ID}/dd-openfeature.jar
490490
- |
491491
cat << EOF > links.json
492492
{
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
plugins {
2+
id 'dd-trace-java.module.instrumentation'
3+
id 'idea'
4+
}
5+
6+
idea {
7+
module {
8+
jdkName = '11'
9+
}
10+
}
11+
12+
// TODO Add a muzzle pass directive on com.datadoghq:dd-openfeature once the SDK is published.
13+
14+
tracerJava {
15+
addSourceSetFor(JavaVersion.VERSION_11)
16+
}
17+
18+
testJvmConstraints {
19+
minJavaVersion = JavaVersion.VERSION_11
20+
}
21+
22+
dependencies {
23+
main_java11CompileOnly project(':dd-openfeature')
24+
main_java11CompileOnly project(':products:feature-flagging:feature-flagging-bootstrap')
25+
main_java11CompileOnly libs.spotbugs.annotations
26+
27+
testImplementation project(':dd-openfeature')
28+
testImplementation project(':products:feature-flagging:feature-flagging-bootstrap')
29+
testImplementation project(':products:feature-flagging:feature-flagging-config')
30+
testImplementation libs.bundles.mockito
31+
}
32+
33+
tasks.named("compileMain_java11Java", JavaCompile) {
34+
configureCompiler(it, JavaVersion.VERSION_11)
35+
}
36+
37+
tasks.named("compileTestJava", JavaCompile) {
38+
configureCompiler(it, JavaVersion.VERSION_11)
39+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# This is a Gradle generated file for dependency locking.
2+
# Manual edits can break the build and are not advised.
3+
# This file is expected to be part of source control.
4+
# To regenerate this file, run: ./gradlew :dd-java-agent:instrumentation:datadog:openfeature:dd-openfeature-connector:dependencies --write-locks
5+
cafe.cryptography:curve25519-elisabeth:0.1.0=testRuntimeClasspath
6+
cafe.cryptography:ed25519-elisabeth:0.1.0=testRuntimeClasspath
7+
ch.qos.logback:logback-classic:1.2.13=testCompileClasspath,testRuntimeClasspath
8+
ch.qos.logback:logback-core:1.2.13=testCompileClasspath,testRuntimeClasspath
9+
com.blogspot.mydailyjava:weak-lock-free:0.17=buildTimeInstrumentationPlugin,compileClasspath,main_java11CompileClasspath,main_java11RuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
10+
com.datadoghq.okhttp3:okhttp:3.12.15=testCompileClasspath,testRuntimeClasspath
11+
com.datadoghq.okio:okio:1.17.6=testCompileClasspath,testRuntimeClasspath
12+
com.datadoghq:dd-instrument-java:0.0.5=buildTimeInstrumentationPlugin,compileClasspath,main_java11CompileClasspath,main_java11RuntimeClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
13+
com.datadoghq:dd-javac-plugin-client:0.2.2=buildTimeInstrumentationPlugin,compileClasspath,main_java11CompileClasspath,main_java11RuntimeClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
14+
com.datadoghq:java-dogstatsd-client:4.4.5=testRuntimeClasspath
15+
com.datadoghq:sketches-java:0.8.3=testRuntimeClasspath
16+
com.fasterxml.jackson.core:jackson-core:2.20.0=main_java11CompileClasspath,testCompileClasspath,testRuntimeClasspath
17+
com.fasterxml.jackson:jackson-bom:2.20.0=main_java11CompileClasspath,testCompileClasspath,testRuntimeClasspath
18+
com.github.javaparser:javaparser-core:3.25.6=codenarc
19+
com.github.jnr:jffi:1.3.15=testRuntimeClasspath
20+
com.github.jnr:jnr-a64asm:1.0.0=testRuntimeClasspath
21+
com.github.jnr:jnr-constants:0.10.4=testRuntimeClasspath
22+
com.github.jnr:jnr-enxio:0.32.20=testRuntimeClasspath
23+
com.github.jnr:jnr-ffi:2.2.19=testRuntimeClasspath
24+
com.github.jnr:jnr-posix:3.1.22=testRuntimeClasspath
25+
com.github.jnr:jnr-unixsocket:0.38.25=testRuntimeClasspath
26+
com.github.jnr:jnr-x86asm:1.0.2=testRuntimeClasspath
27+
com.github.spotbugs:spotbugs-annotations:4.10.4=compileClasspath,main_java11CompileClasspath,spotbugs
28+
com.github.spotbugs:spotbugs:4.10.4=spotbugs
29+
com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs
30+
com.google.auto.service:auto-service-annotations:1.1.1=annotationProcessor,compileClasspath,testAnnotationProcessor,testCompileClasspath
31+
com.google.auto.service:auto-service:1.1.1=annotationProcessor,testAnnotationProcessor
32+
com.google.auto:auto-common:1.2.1=annotationProcessor,testAnnotationProcessor
33+
com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,compileClasspath,main_java11CompileClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
34+
com.google.code.gson:gson:2.14.0=spotbugs
35+
com.google.errorprone:error_prone_annotations:2.18.0=annotationProcessor,testAnnotationProcessor
36+
com.google.errorprone:error_prone_annotations:2.47.0=testCompileClasspath,testRuntimeClasspath
37+
com.google.errorprone:error_prone_annotations:2.48.0=spotbugs
38+
com.google.guava:failureaccess:1.0.1=annotationProcessor,testAnnotationProcessor
39+
com.google.guava:failureaccess:1.0.3=testCompileClasspath,testRuntimeClasspath
40+
com.google.guava:guava:32.0.1-jre=annotationProcessor,testAnnotationProcessor
41+
com.google.guava:guava:33.6.0-jre=testCompileClasspath,testRuntimeClasspath
42+
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
43+
com.google.j2objc:j2objc-annotations:2.8=annotationProcessor,testAnnotationProcessor
44+
com.google.j2objc:j2objc-annotations:3.1=testCompileClasspath,testRuntimeClasspath
45+
com.google.re2j:re2j:1.8=testRuntimeClasspath
46+
com.squareup.moshi:moshi:1.11.0=testCompileClasspath,testRuntimeClasspath
47+
com.squareup.okhttp3:logging-interceptor:3.12.12=testCompileClasspath,testRuntimeClasspath
48+
com.squareup.okhttp3:okhttp:3.12.12=testCompileClasspath,testRuntimeClasspath
49+
com.squareup.okio:okio:1.17.5=testCompileClasspath,testRuntimeClasspath
50+
com.thoughtworks.qdox:qdox:1.12.1=codenarc
51+
commons-fileupload:commons-fileupload:1.5=testCompileClasspath,testRuntimeClasspath
52+
commons-io:commons-io:2.11.0=testCompileClasspath,testRuntimeClasspath
53+
commons-io:commons-io:2.21.0=spotbugs
54+
de.thetaphi:forbiddenapis:3.11=compileClasspath,testCompileClasspath,testRuntimeClasspath
55+
dev.openfeature:sdk:1.22.0=main_java11CompileClasspath,testCompileClasspath,testRuntimeClasspath
56+
io.leangen.geantyref:geantyref:1.3.16=testRuntimeClasspath
57+
io.opentelemetry:opentelemetry-api:1.66.0=main_java11CompileClasspath,testCompileClasspath,testRuntimeClasspath
58+
io.opentelemetry:opentelemetry-common:1.66.0=main_java11CompileClasspath,testCompileClasspath,testRuntimeClasspath
59+
io.opentelemetry:opentelemetry-context:1.66.0=main_java11CompileClasspath,testCompileClasspath,testRuntimeClasspath
60+
io.sqreen:libsqreen:17.5.0=testRuntimeClasspath
61+
javax.servlet:javax.servlet-api:3.1.0=testCompileClasspath,testRuntimeClasspath
62+
jaxen:jaxen:2.0.6=spotbugs
63+
junit:junit:4.13.2=testRuntimeClasspath
64+
net.bytebuddy:byte-buddy-agent:1.18.12=buildTimeInstrumentationPlugin,compileClasspath,main_java11CompileClasspath,main_java11RuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
65+
net.bytebuddy:byte-buddy:1.18.12=buildTimeInstrumentationPlugin,compileClasspath,main_java11CompileClasspath,main_java11RuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
66+
net.java.dev.jna:jna-platform:5.8.0=testRuntimeClasspath
67+
net.java.dev.jna:jna:5.8.0=testRuntimeClasspath
68+
net.sf.saxon:Saxon-HE:12.10=spotbugs
69+
org.apache.ant:ant-antlr:1.10.14=codenarc
70+
org.apache.ant:ant-junit:1.10.14=codenarc
71+
org.apache.bcel:bcel:6.12.0=spotbugs
72+
org.apache.commons:commons-lang3:3.20.0=spotbugs
73+
org.apache.commons:commons-text:1.15.0=spotbugs
74+
org.apache.logging.log4j:log4j-api:2.26.1=spotbugs
75+
org.apache.logging.log4j:log4j-core:2.26.1=spotbugs
76+
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testRuntimeClasspath
77+
org.checkerframework:checker-qual:3.33.0=annotationProcessor,testAnnotationProcessor
78+
org.codehaus.groovy:groovy-ant:3.0.23=codenarc
79+
org.codehaus.groovy:groovy-docgenerator:3.0.23=codenarc
80+
org.codehaus.groovy:groovy-groovydoc:3.0.23=codenarc
81+
org.codehaus.groovy:groovy-json:3.0.23=codenarc
82+
org.codehaus.groovy:groovy-json:3.0.25=testCompileClasspath,testRuntimeClasspath
83+
org.codehaus.groovy:groovy-templates:3.0.23=codenarc
84+
org.codehaus.groovy:groovy-xml:3.0.23=codenarc
85+
org.codehaus.groovy:groovy:3.0.23=codenarc
86+
org.codehaus.groovy:groovy:3.0.25=testCompileClasspath,testRuntimeClasspath
87+
org.codenarc:CodeNarc:3.7.0=codenarc
88+
org.dom4j:dom4j:2.2.0=spotbugs
89+
org.gmetrics:GMetrics:2.1.0=codenarc
90+
org.hamcrest:hamcrest-core:1.3=testRuntimeClasspath
91+
org.hamcrest:hamcrest:3.0=testCompileClasspath,testRuntimeClasspath
92+
org.jctools:jctools-core-jdk11:4.0.6=testRuntimeClasspath
93+
org.jctools:jctools-core:4.0.6=testRuntimeClasspath
94+
org.jspecify:jspecify:1.0.0=testCompileClasspath,testRuntimeClasspath
95+
org.junit.jupiter:junit-jupiter-api:5.14.1=testCompileClasspath,testRuntimeClasspath
96+
org.junit.jupiter:junit-jupiter-engine:5.14.1=testRuntimeClasspath
97+
org.junit.jupiter:junit-jupiter-params:5.14.1=testCompileClasspath,testRuntimeClasspath
98+
org.junit.jupiter:junit-jupiter:5.14.1=testCompileClasspath,testRuntimeClasspath
99+
org.junit.platform:junit-platform-commons:1.14.1=testCompileClasspath,testRuntimeClasspath
100+
org.junit.platform:junit-platform-engine:1.14.1=testCompileClasspath,testRuntimeClasspath
101+
org.junit.platform:junit-platform-launcher:1.14.1=testRuntimeClasspath
102+
org.junit.platform:junit-platform-runner:1.14.1=testRuntimeClasspath
103+
org.junit.platform:junit-platform-suite-api:1.14.1=testRuntimeClasspath
104+
org.junit.platform:junit-platform-suite-commons:1.14.1=testRuntimeClasspath
105+
org.junit:junit-bom:5.14.1=testCompileClasspath,testRuntimeClasspath
106+
org.mockito:mockito-core:4.4.0=testCompileClasspath,testRuntimeClasspath
107+
org.mockito:mockito-junit-jupiter:4.4.0=testCompileClasspath,testRuntimeClasspath
108+
org.objenesis:objenesis:3.3=testCompileClasspath,testRuntimeClasspath
109+
org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath
110+
org.ow2.asm:asm-analysis:9.10.1=spotbugs
111+
org.ow2.asm:asm-analysis:9.7.1=testRuntimeClasspath
112+
org.ow2.asm:asm-commons:9.10.1=spotbugs,testRuntimeClasspath
113+
org.ow2.asm:asm-tree:9.10.1=spotbugs,testRuntimeClasspath
114+
org.ow2.asm:asm-util:9.10.1=spotbugs
115+
org.ow2.asm:asm-util:9.7.1=testRuntimeClasspath
116+
org.ow2.asm:asm:9.10.1=buildTimeInstrumentationPlugin,compileClasspath,main_java11CompileClasspath,main_java11RuntimeClasspath,muzzleTooling,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
117+
org.slf4j:jcl-over-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
118+
org.slf4j:jul-to-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
119+
org.slf4j:log4j-over-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
120+
org.slf4j:slf4j-api:1.7.30=buildTimeInstrumentationPlugin,compileClasspath,main_java11RuntimeClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath
121+
org.slf4j:slf4j-api:2.0.17=spotbugsSlf4j
122+
org.slf4j:slf4j-api:2.0.18=main_java11CompileClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
123+
org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j
124+
org.snakeyaml:snakeyaml-engine:2.9=buildTimeInstrumentationPlugin,main_java11RuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath
125+
org.spockframework:spock-bom:2.4-groovy-3.0=testCompileClasspath,testRuntimeClasspath
126+
org.spockframework:spock-core:2.4-groovy-3.0=testCompileClasspath,testRuntimeClasspath
127+
org.tabletest:tabletest-junit:1.2.2=testCompileClasspath,testRuntimeClasspath
128+
org.tabletest:tabletest-parser:1.2.1=testCompileClasspath,testRuntimeClasspath
129+
org.xmlresolver:xmlresolver:5.3.3=spotbugs
130+
empty=main_java11AnnotationProcessor,spotbugsPlugins
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package datadog.trace.instrumentation.openfeature;
2+
3+
import static datadog.trace.agent.tooling.InstrumenterModule.TargetSystem.FEATURE_FLAGS;
4+
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
5+
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
6+
import static net.bytebuddy.matcher.ElementMatchers.isStatic;
7+
import static net.bytebuddy.matcher.ElementMatchers.takesNoArguments;
8+
9+
import com.google.auto.service.AutoService;
10+
import datadog.trace.agent.tooling.Instrumenter;
11+
import datadog.trace.agent.tooling.InstrumenterModule;
12+
import java.util.Set;
13+
14+
/**
15+
* Connects the {@code dd-openfeature} SDK to the agent: Remote Configuration, the event platform
16+
* proxy, health metrics and span enrichment.
17+
*/
18+
@SuppressWarnings("unused")
19+
@AutoService(InstrumenterModule.class)
20+
public class DDOpenFeatureInstrumentation extends InstrumenterModule
21+
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {
22+
23+
public DDOpenFeatureInstrumentation() {
24+
super("openfeature");
25+
}
26+
27+
@Override
28+
public boolean isApplicable(final Set<TargetSystem> enabledSystems) {
29+
return enabledSystems.contains(FEATURE_FLAGS);
30+
}
31+
32+
@Override
33+
public String instrumentedType() {
34+
return "com.datadog.openfeature.internal.connector.Connectors";
35+
}
36+
37+
@Override
38+
public String[] helperClassNames() {
39+
// Helpers are compiled in the java11 source set, out of reach of helper discovery.
40+
return new String[] {
41+
packageName + ".AgentConfigurationSource",
42+
packageName + ".AgentEventProxy",
43+
packageName + ".AgentHealthMetrics",
44+
packageName + ".AgentSpanEnricher",
45+
packageName + ".JavaAgentConnector",
46+
};
47+
}
48+
49+
@Override
50+
public void methodAdvice(final MethodTransformer transformer) {
51+
transformer.applyAdvice(
52+
isMethod().and(isStatic()).and(named("detect")).and(takesNoArguments()),
53+
packageName + ".DetectConnectorAdvice");
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package datadog.trace.instrumentation.openfeature;
2+
3+
import com.datadog.openfeature.internal.connector.ConfigurationSource;
4+
import datadog.trace.api.featureflag.FeatureFlaggingGateway;
5+
import java.util.function.Consumer;
6+
7+
/** Receives the flag configuration from the agent Remote Configuration client. */
8+
public final class AgentConfigurationSource implements ConfigurationSource {
9+
private final FeatureFlaggingGateway.Backend backend;
10+
11+
AgentConfigurationSource(final FeatureFlaggingGateway.Backend backend) {
12+
this.backend = backend;
13+
}
14+
15+
@Override
16+
public AutoCloseable subscribe(final Consumer<byte[]> listener) {
17+
return this.backend.subscribeRemoteConfig(listener);
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package datadog.trace.instrumentation.openfeature;
2+
3+
import com.datadog.openfeature.internal.connector.EventProxyUnavailableException;
4+
import com.datadog.openfeature.internal.connector.EventTransport;
5+
import datadog.trace.api.featureflag.FeatureFlaggingGateway;
6+
import java.io.IOException;
7+
8+
/** Posts events through the Datadog Agent event platform proxy. */
9+
public final class AgentEventProxy implements EventTransport {
10+
private final FeatureFlaggingGateway.Backend backend;
11+
12+
AgentEventProxy(final FeatureFlaggingGateway.Backend backend) {
13+
this.backend = backend;
14+
}
15+
16+
@Override
17+
public void post(final String route, final byte[] json) throws IOException {
18+
if (!this.backend.postEvent(route, json)) {
19+
throw new EventProxyUnavailableException("Datadog Agent event platform proxy unavailable");
20+
}
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package datadog.trace.instrumentation.openfeature;
2+
3+
import com.datadog.openfeature.internal.connector.HealthMetrics;
4+
import datadog.trace.api.featureflag.FeatureFlaggingGateway;
5+
import javax.annotation.Nullable;
6+
7+
/** Reports the SDK health counters through the agent telemetry. */
8+
public final class AgentHealthMetrics implements HealthMetrics {
9+
private final FeatureFlaggingGateway.Backend backend;
10+
11+
AgentHealthMetrics(final FeatureFlaggingGateway.Backend backend) {
12+
this.backend = backend;
13+
}
14+
15+
@Override
16+
public void count(final String metric, final long value, @Nullable final String reason) {
17+
this.backend.count(metric, value, reason);
18+
}
19+
}

0 commit comments

Comments
 (0)