open-feature / java-sdk-contrib Goto Github PK
View Code? Open in Web Editor NEWCommunity contributions for hooks and reference providers
Home Page: https://openfeature.dev
License: Apache License 2.0
Community contributions for hooks and reference providers
Home Page: https://openfeature.dev
License: Apache License 2.0
https://github.com/open-feature/java-sdk-contrib/blob/main/providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/FlagdProvider.java#L56
It's not always guaranteed that FeatureProvider.shutdown()
method is called at the end of application lifecycle. The user can call the shutdown method at any point in time of application lifetime. So it's better to reset the state. may be NOT_READY or new state and publish the event with the new state.
Background
Consider OFEP [1] - open-feature/ofep#62
Go-SDK hook implementation is ready[2] and this issue focuses on Java-sdk implementation of the hook.
Outcome
OTel hooks for metrics as define by OFEP
[1] - open-feature/ofep#62
[2] - open-feature/go-sdk-contrib#217
See #244 (comment)
Minor comment (potential improvement)
We could make this an interface (contract) and have a default implementation based on System.getenv(name)
That would allow having custom env variable handling (ex:- prefixes, casing and even sources like spring configurations which come from different sources [1] ) and still use the same provider
Could be a follow up work :)
See here, and the linked issue for details and background. This blog post is also helpful, specifically for library maintainers.
In each module in this project, we should add this maven step (we could also add it in the parent POM and somehow grab the name dynamically). We should be careful that the module name matches the "highest level" package in the module.
Once the java-sdk has events
and init/shutdown
support, we need to update the flagd-provider to emit events and do proper init/shutdown. We already have a stream implemented for cache-busing, so this should be pretty simple.
Definition of done:
initialize
functionclose/shutdown
functionBlocked by:
Resources:
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
org.mockito:mockito-inline
, org.mockito:mockito-junit-jupiter
, org.mockito:mockito-core
)providers/flagd/docker-compose.yaml
.github/workflows/ci.yml
actions/checkout v4@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
actions/setup-java v4@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
actions/cache v4@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
ghcr.io/open-feature/flagd-testbed v0.5.4
ghcr.io/open-feature/flagd-testbed-unstable v0.5.4
ghcr.io/open-feature/sync-testbed v0.5.4
ghcr.io/open-feature/sync-testbed-unstable v0.5.4
.github/workflows/component-owners.yml
dyladan/component-owners cdaadffde64c918909ee081e3fe044b8910f56c2
.github/workflows/lint-pr.yml
amannn/action-semantic-pull-request v5@e9fabac35e210fea40ca5b14c0da95a099eff26f
.github/workflows/release-please.yml
google-github-actions/release-please-action v4@a37ac6e4f6449ce8b3f7607e4d97d0146028dc0b
actions/checkout v4@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
actions/setup-java v4@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
actions/cache v4@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
hooks/open-telemetry/pom.xml
io.opentelemetry:opentelemetry-bom 1.38.0
dev.openfeature:sdk [1.4,2.0)
io.opentelemetry:opentelemetry-semconv 1.30.1-alpha
pom.xml
dev.openfeature:sdk [1.0,2.0)
org.projectlombok:lombok 1.18.32
com.github.spotbugs:spotbugs 4.8.5
org.mockito:mockito-core 4.11.0
uk.org.lidalia:slf4j-test 1.2.0
org.assertj:assertj-core 3.25.3
org.junit.jupiter:junit-jupiter 5.10.2
org.junit.jupiter:junit-jupiter-engine 5.10.2
org.junit.jupiter:junit-jupiter-api 5.10.2
org.junit.jupiter:junit-jupiter-params 5.10.2
org.junit.platform:junit-platform-suite 1.10.2
org.mockito:mockito-junit-jupiter 4.11.0
org.mockito:mockito-inline 4.11.0
uk.org.webcompere:system-stubs-core 2.0.3
uk.org.webcompere:system-stubs-jupiter 2.1.6
io.cucumber:cucumber-java 7.17.0
io.cucumber:cucumber-junit-platform-engine 7.17.0
org.awaitility:awaitility 4.2.1
org.apache.maven.plugins:maven-compiler-plugin 3.13.0
org.apache.maven.plugins:maven-surefire-plugin 3.2.5
org.apache.maven.plugins:maven-checkstyle-plugin 3.3.1
com.puppycrawl.tools:checkstyle 8.45.1
org.apache.maven.plugins:maven-pmd-plugin 3.21.2
com.github.spotbugs:spotbugs-maven-plugin 4.8.5.0
com.h3xstream.findsecbugs:findsecbugs-plugin 1.13.0
com.github.spotbugs:spotbugs 4.8.5
org.apache.maven.plugins:maven-jar-plugin 3.4.1
org.honton.chas:exists-maven-plugin 0.7.0
org.apache.maven.plugins:maven-source-plugin 3.3.1
org.apache.maven.plugins:maven-javadoc-plugin 3.6.3
org.cyclonedx:cyclonedx-maven-plugin 2.8.0
org.apache.maven.plugins:maven-gpg-plugin 3.2.4
org.sonatype.plugins:nexus-staging-maven-plugin 1.6.13
providers/configcat/pom.xml
com.configcat:configcat-java-client 9.1.2
org.slf4j:slf4j-api 2.0.13
org.apache.logging.log4j:log4j-slf4j2-impl 2.23.1
providers/env-var/pom.xml
org.apache.commons:commons-lang3 3.14.0
providers/flagd/pom.xml
dev.openfeature:sdk [1.4,2.0)
io.grpc:grpc-netty 1.63.0
io.grpc:grpc-protobuf 1.63.0
io.grpc:grpc-stub 1.63.0
io.netty:netty-transport-native-epoll 4.1.109.Final
com.fasterxml.jackson.core:jackson-databind 2.17.1
io.github.jamsesso:json-logic-java 1.0.7
com.google.code.gson:gson 2.10.1
com.networknt:json-schema-validator 1.4.0
org.apache.tomcat:annotations-api 6.0.53
org.apache.commons:commons-collections4 4.4
io.opentelemetry:opentelemetry-api 1.38.0
org.semver4j:semver4j 5.3.0
commons-codec:commons-codec 1.17.0
kr.motd.maven:os-maven-plugin 1.7.1
org.codehaus.mojo:exec-maven-plugin 3.2.0
org.xolstice.maven.plugins:protobuf-maven-plugin 0.6.1
org.codehaus.mojo:exec-maven-plugin 3.2.0
providers/flagsmith/pom.xml
com.flagsmith:flagsmith-java-client 7.3.0
com.squareup.okhttp3:okhttp 4.12.0
com.squareup.okhttp3:mockwebserver 4.12.0
providers/flipt/pom.xml
io.flipt:flipt-java 1.1.1
org.slf4j:slf4j-api 2.0.13
com.github.tomakehurst:wiremock-jre8 2.35.2
com.fasterxml.jackson.core:jackson-core 2.17.1
com.fasterxml.jackson.core:jackson-databind 2.17.1
com.fasterxml.jackson.core:jackson-annotations 2.17.1
org.apache.logging.log4j:log4j-slf4j2-impl 2.23.1
providers/go-feature-flag/pom.xml
com.fasterxml.jackson.datatype:jackson-datatype-jsr310 2.17.1
com.fasterxml.jackson.core:jackson-databind 2.17.1
com.squareup.okhttp3:okhttp 4.12.0
com.squareup.okhttp3:mockwebserver 4.12.0
com.google.guava:guava 33.2.0-jre
org.slf4j:slf4j-api 2.0.13
org.apache.logging.log4j:log4j-slf4j2-impl 2.23.1
providers/jsonlogic-eval-provider/pom.xml
io.github.jamsesso:json-logic-java 1.0.7
org.json:json 20240303
com.github.spotbugs:spotbugs-annotations 4.8.5
providers/statsig/pom.xml
com.statsig:serversdk 1.17.3
org.slf4j:slf4j-api 2.0.13
org.apache.logging.log4j:log4j-slf4j2-impl 2.23.1
providers/unleash/pom.xml
io.getunleash:unleash-client-java 9.2.1
org.slf4j:slf4j-api 2.0.13
com.github.tomakehurst:wiremock-jre8 2.35.2
org.apache.logging.log4j:log4j-slf4j2-impl 2.23.1
We have a null pointer when the field anonymous is not set in the GO Feature Flag provider.
This issue is here for me to remember to work on it.
We need to configure renovate.
The testing harness has introduced a caching suite, tests for this should be implemented.
The flagd provider should start an OTel span that will be passed to flagd to get cross-service tracing for evaluation.
Add OTel hook implementation plus tests.
See https://github.com/open-feature/node-sdk-contrib/tree/main/libs/hooks/open-telemetry
Moved from: open-feature/java-sdk#339
JS SDK already has a simple env var provider implementation here. It may be used as an example.
log.debug
statementsAdd a contributing document to the root of the repo. People interested in contributing for the first time can use this document to understand how they should get started. For a basic example, please refer to the contributing docs in the js contrib repo.
Similar to go sdk hook, the java hook can be improved with the Span error state
Full context - open-feature/go-sdk-contrib#204
The current implementation of OpenFeature's error hook in otel does not set the span status to error, despite it being recommended in the OTEL specification to do so
Also, consider providing an option to override default behavior as highlighted at open-feature/go-sdk-contrib#208
Currently it's possible to map flag metadata values to custom OTel attributes (see here). However this approach has limitations, as it can only map values 1:1.
We should implement something similar to the JS implementation, which allows consumers to provide a function that takes the flag metadata and returns OTel attributes.
We should add the same functionality to the Tracing hook.
Implement caching based on the strategy defined here.
Go implementation, for reference: open-feature/go-sdk-contrib#48
We need to absorb the (minor) changes from: open-feature/java-sdk#61
Add a CODEOWNERS file with appropriate persons per artifact, as well as root-level CODEOWNERS.
We don't yet have e2e tests for flag changes or zero-value flags.
These are both defined in the flagd.feature test suite, and supported by the sync-testbed
and flagd-testbed
containers.
Tasks:
Flag change event
should fire automatically from both testbed containers, so there's no need to manually change the flagsflagd includes scope
as a flag evaluation metadata 1 which correlates to grpc proxy selector
2. Given in-process evaluator can works with grpc proxy, we can include scope
in in-process implementation.
Acceptance Criteria
In-process provider with grpc flag syncs includes selector as scope
in flag evaluation metadata similar to flagd implementation.
We can probably use generics/lambdas to reduce some duplication across the resolvers.
The flagd in-process evaluator needs to have $flagd.timestamp
added, so that users can write time-based JsonLogic rules.
See here for doc, and here for the flagd-standalone implementation.
You'll need to add a standard unix timestamp (seconds since 1970) to the evaluation context, similar to the flagKey, here.
When evaluating a flag via the client, provider should handle cases like:
if not supported, handle accordingly with a proper error code and documentation.
Implement this.
Self-assigning.
Currently the flagd provider doesn't default to unlimited retries, and doesn't throw immediately if it can't start.
See: https://github.com/open-feature/flagd/blob/main/docs/other_resources/creating_providers.md#environment-variables and https://github.com/open-feature/flagd/blob/main/docs/other_resources/creating_providers.md#provider-lifecycle-initialization-and-shutdown
Definition of done:
Similar to go-sdk provider, we should allow to configure java provider's offline flag source path from an environment variable.
For consistency use same variable name - FLAGD_OFFLINE_FLAG_SOURCE_PATH
AC
Env variable is available and documentation updated accordingly
See - Originally posted by @Kavindu-Dodan in open-feature/go-sdk-contrib#421 (comment)
Flagsmith provider class and option class was created using package restricted access, so examples doesn't work.
For each artifact, we should include and SBOM. It should be published similar to the java-sdk's SBOM.
As per the recommendation from netty, we should add a guard before loading the Epoll classes. It seems like they will revert the change that caused our issue, but using this guard will also help us to give helpful error messages if this native lib is missing.
With the addition of the new protos (flagd.evaluation.v1, flagd.sync.v1), we must update all clients (flagd providers) to use these endpoints.
In Java the associated code is already being generated by the build process, we must simply use the new classes generated with the new protos.
new protos in buf: https://buf.build/open-feature/flagd
new proto source: https://github.com/open-feature/flagd-schemas/tree/main/protobuf/flagd
Flagd sends empty values in flag response payloads when the value is equivalent to the zero-value of the associated go type. We should test that this works as expected and still returns an equivalent zero-value (ie: false
, 0
).
DoD:
The flagd in-process provider should be able to resolve ints as floats, and vice-versa.
To fix:
Background:
Originally posted by @toddbaert in #468 (comment)
As suggested by this comment, our concurrency logic needs to be validated for race conditions. Though we expect initialization to be called once, there could be edge cases such as multiple provider registrations which could invoke unwanted initialization attempts.
Acceptance Criteria
In-process provider implementation is validated for potential race conditions and fixed.
This should be similar to what's in the java-sdk now.
Definition of done:
flagd's convertPrimitive(Value)
results in an NPE as we explicitly set null
[1] for context null values.
This must be corrected by using NullValue
[2], which allows the representation to accept null values.
[1] - https://github.com/open-feature/java-sdk-contrib/blob/dev.openfeature.contrib.providers.flagd-v0.5.7/providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/FlagdProvider.java#L389
[2] - https://protobuf.dev/reference/java/api-docs/com/google/protobuf/NullValue.html
As mentioned in flagd documentation of Creating an in-process flagd provider 1, in-process provider comes with unique advantages. This issue focuses on creating the first version of flagd in-process provider in Java.
Requirements
Technical requirements
providers/flagd
)Tasks
We can consider implementing https://github.com/apps/sonarcloud, which is free for OSS projects. The CNCF doesn't seem to provide any free SAST tools.
Now that OTel 2529 is merged, we should implement the Open Telemetry hook (currently exists as a stub).
Basically, this would entail creating a hook which:
after
stage: gets the current span and adds an appropriately named event (feature_flag
), with the attributes (feature_flag.key
, feature_flag.provider_name
, and feature_flag.variant
)error
stage, records the exceptionIn pseudocode, this looks something like:
class OTelHook implements Hook {
after(context, details) {
var currentTrace = trace.getActiveSpan();
currentTrace.addEvent("feature_flag", { "feature_flag.key": details.key, /* other props */ } );
}
error(err) {
var currentTrace = trace.getActiveSpan();
currentTrace.recordException(err);
}
}
The JS and Go version options look like this:
| Option name | Environment variable name | Type | Default |
| ----------- | ------------------------- | ------- | --------- |
| host | FLAGD_HOST | string | localhost |
| port | FLAGD_PORT | number | 8013 |
| tls | FLAGD_TLS | boolean | false |
| socketPath | FLAGD_SOCKET_PATH | string | - |
| certPath | FLAGD_SERVER_CERT_PATH | string | - |
We need to change the config to look like this, and add certPath
and socketPath
support.
This will also fix a bug with an unexported Protocol
enum.
Should include:
See #244 (comment):
One thing we've done in other ENV VAR providers is to map SCREAMING_SNAKE_CASE env vars to hyphen-case-keys. This may be desirable, since generally people like to use SCREAMIN_SNAKE for env vars, but that's generally not true for feature flag keys.
You could also create some transformer interface to allow users to control this translation.... and it doesn't have to be done in this PR.
Remove the methods annotated with @Deprecated
in providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/FlagdProvider.java
With #294, several methods are deprecated because we moved to a builder pattern. We should remove them and the respective test code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.