Giter VIP home page Giter VIP logo

java-sdk-contrib's Introduction

OpenFeature Java Contributions

FOSSA Status

This repository is intended for OpenFeature contributions which are not included in the OpenFeature SDK.

The project includes:

Releases

This repo uses Release Please to release packages. Release Please sets up a running PR that tracks all changes for the library components, and maintains the versions according to conventional commits, generated when PRs are merged. When Release Please's running PR is merged, any changed artifacts are published.

Software Bill of Materials (SBOM)

We publish SBOMs with all of our releases. You can find them in Maven Central alongside the artifacts.

Contributing

see: CONTRIBUTING.md

License

Apache 2.0 - See LICENSE for more information.

FOSSA Status

java-sdk-contrib's People

Contributors

aepfli avatar ajhelsby avatar alexandraoberaigner avatar beeme1mr avatar colebaileygit avatar dblanchard88 avatar fossabot avatar github-actions[bot] avatar itchyny avatar justinabrahms avatar kavindu-dodan avatar liran2000 avatar lopitz avatar madhead avatar markphelps avatar mehtasankets avatar morganblanloeil avatar odubajdt avatar prathyk avatar renovate[bot] avatar robbert229 avatar rolodato avatar skyerus avatar thisthat avatar thiyagu06 avatar thomaspoignant avatar toddbaert avatar zedadyna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-sdk-contrib's Issues

[FlagD] Refactor package structure and offload some responsibilities from FlagdProvider

Problems

  • Everything is bundled together into a single namespace which makes it hard to understand the responsibilities of each class.
  • The current main commit allows for external entities to change the internal state of the communication of Flagd Provider. IMHO we should remove this from the API surface.
  • Unit and Integration tests are hard to write
  • Review opportunities to add log.debug statements

Suggestion

Refactor into modules as proposed:
image

Add CODEOWNERS

Add a CODEOWNERS file with appropriate persons per artifact, as well as root-level CODEOWNERS.

Flagsmith classes not public

Flagsmith provider class and option class was created using package restricted access, so examples doesn't work.

[env-var-provider] Replace OS class with an interface

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 :)

[1] - https://docs.spring.io/spring-boot/docs/1.0.1.RELEASE/reference/html/boot-features-external-config.html

[flagd] implement `flagd.feature` gherkin test suite

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:

  • add matching steps defined in the feature file to the steps
    • note the Flag change event should fire automatically from both testbed containers, so there's no need to manually change the flags
  • load the feature file in both cucumber runs (RPC and in-process)

[flagd] validate race conditions of in-process provider

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.

[flagd-provider] add events support

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:

  • flagd does does startup logic (like initializing its stream) in initialize function
  • flagd shuts down stream in close/shutdown function
  • flagd emits appropriate events on flag changes, and errors
  • associated testing

Blocked by:

Resources:

OTel Span in flagd Provider

The flagd provider should start an OTel span that will be passed to flagd to get cross-service tracing for evaluation.

[flagd] Default port to 8015 if in-process resolver is used.

The flagd provider defaults to RPC mode and the corresponding port (8013) using the evaluation proto. If the in-process resolver is selected, it operates in in-process mode using the sync proto, but still uses port 8013, instead of defaulting to the correct port (8015, for the sync proto).

We should improve the configuration by defaulting to port 8015 if the in-process resolver is selected.

[flagd] shutting down provider should reset the state.

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.

[flagd] follow-up refactoring

Tasks

[flagd] Intial version of in-process provider

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

  • Fulfill requirements outlined by flagd in-process guideline 1
  • Minimal external dependencies
  • Updated/New ReadMe & usage guide
  • Unit & Integration tests

Technical requirements

  • Use the same repository directory structure (providers/flagd)
  • Build both remote and in-process providers into a single dependency (To be decided after the POC)
  • Reuse existing interfaces and implementations where possible

Tasks

  • POC implementation and build to detect packaging requirements (no evaluations needed)
  • In-process provider with gRPC flag sync capability on basic flags
  • Support for JsonLogic evaluators (complex flagd flag configurations)
  • Support for flagd custom JsonLogic evaluators

Footnotes

  1. https://github.com/open-feature/flagd/blob/main/docs/other_resources/in-process-providers/specification.md 2

[feat] add JUnit Pioneer to dev dependencies

While developing #810, we saw the need for overwriting environment variables during testing. As this is not a trivial task to do, we looked for easy-to-use alternatives in the JUnit world and 'stumbled' upon JUnit Pioneer.

JUnit Pioneer offers a great set of additional utilities for JUnit tests, like setting env variables, setting system properties, default locales, etc. This could be a great extension of our testing capabilities without adding another dependency for our provided libraries.o

wdyt?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4@692973e3d937129bcbf40652eb9f2f61becf3332
  • actions/setup-java v4@6a0805fcefea3d4657a47ac4c165951e33482018
  • actions/cache v4@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
.github/workflows/component-owners.yml
  • dyladan/component-owners 58bd86e9814d23f1525d0a970682cead459fa783
.github/workflows/lint-pr.yml
  • amannn/action-semantic-pull-request v5@0723387faaf9b38adef4775cd42cfd5155ed6017
.github/workflows/release-please.yml
  • google-github-actions/release-please-action v4@e4dc86ba9405554aeba3c6bb2d169500e7d3b4ee
  • actions/checkout v4@692973e3d937129bcbf40652eb9f2f61becf3332
  • actions/setup-java v4@6a0805fcefea3d4657a47ac4c165951e33482018
  • actions/cache v4@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
maven
hooks/open-telemetry/pom.xml
  • io.opentelemetry:opentelemetry-bom 1.41.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.34
  • com.github.spotbugs:spotbugs 4.8.6
  • org.mockito:mockito-core 4.11.0
  • uk.org.lidalia:slf4j-test 1.2.0
  • org.assertj:assertj-core 3.26.3
  • org.junit.jupiter:junit-jupiter 5.11.0
  • org.junit.jupiter:junit-jupiter-engine 5.11.0
  • org.junit.jupiter:junit-jupiter-api 5.11.0
  • org.junit.jupiter:junit-jupiter-params 5.11.0
  • org.junit.platform:junit-platform-suite 1.11.0
  • org.junit-pioneer:junit-pioneer 1.9.1
  • 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.18.1
  • io.cucumber:cucumber-junit-platform-engine 7.18.1
  • org.awaitility:awaitility 4.2.2
  • org.apache.maven.plugins:maven-compiler-plugin 3.13.0
  • org.apache.maven.plugins:maven-surefire-plugin 3.3.1
  • org.apache.maven.plugins:maven-checkstyle-plugin 3.4.0
  • com.puppycrawl.tools:checkstyle 8.45.1
  • org.apache.maven.plugins:maven-pmd-plugin 3.24.0
  • com.github.spotbugs:spotbugs-maven-plugin 4.8.6.2
  • com.h3xstream.findsecbugs:findsecbugs-plugin 1.13.0
  • com.github.spotbugs:spotbugs 4.8.6
  • org.apache.maven.plugins:maven-jar-plugin 3.4.2
  • 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.8.0
  • org.cyclonedx:cyclonedx-maven-plugin 2.8.1
  • org.apache.maven.plugins:maven-gpg-plugin 3.2.5
  • org.sonatype.plugins:nexus-staging-maven-plugin 1.7.0
  • org.junit.jupiter:junit-jupiter-api 5.11.0
providers/configcat/pom.xml
  • com.configcat:configcat-java-client 9.4.1
  • org.slf4j:slf4j-api 2.0.16
  • org.apache.logging.log4j:log4j-slf4j2-impl 2.23.1
providers/env-var/pom.xml
  • org.apache.commons:commons-lang3 3.16.0
providers/flagd/pom.xml
  • dev.openfeature:sdk [1.4,2.0)
  • io.grpc:grpc-netty 1.66.0
  • io.grpc:grpc-protobuf 1.66.0
  • io.grpc:grpc-stub 1.66.0
  • io.netty:netty-transport-native-epoll 4.1.112.Final
  • com.fasterxml.jackson.core:jackson-databind 2.17.2
  • io.github.jamsesso:json-logic-java 1.0.7
  • com.google.code.gson:gson 2.11.0
  • com.networknt:json-schema-validator 1.5.1
  • org.apache.tomcat:annotations-api 6.0.53
  • org.apache.commons:commons-collections4 4.4
  • io.opentelemetry:opentelemetry-api 1.41.0
  • org.semver4j:semver4j 5.3.0
  • commons-codec:commons-codec 1.17.1
  • org.junit.jupiter:junit-jupiter 5.11.0
  • org.testcontainers:testcontainers 1.20.1
  • org.testcontainers:junit-jupiter 1.20.1
  • kr.motd.maven:os-maven-plugin 1.7.1
  • org.codehaus.mojo:exec-maven-plugin 3.4.1
  • org.xolstice.maven.plugins:protobuf-maven-plugin 0.6.1
  • org.codehaus.mojo:exec-maven-plugin 3.4.1
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.16
  • com.github.tomakehurst:wiremock-jre8 2.35.2
  • com.fasterxml.jackson.core:jackson-core 2.17.2
  • com.fasterxml.jackson.core:jackson-databind 2.17.2
  • com.fasterxml.jackson.core:jackson-annotations 2.17.2
  • 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.2
  • com.fasterxml.jackson.core:jackson-databind 2.17.2
  • com.squareup.okhttp3:okhttp 4.12.0
  • com.squareup.okhttp3:mockwebserver 4.12.0
  • com.google.guava:guava 33.2.1-jre
  • org.slf4j:slf4j-api 2.0.16
  • io.reactivex.rxjava3:rxjava 3.1.9
  • 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.6
providers/statsig/pom.xml
  • com.statsig:serversdk 1.18.1
  • org.slf4j:slf4j-api 2.0.16
  • org.apache.logging.log4j:log4j-slf4j2-impl 2.23.1
providers/unleash/pom.xml
  • io.getunleash:unleash-client-java 9.2.4
  • org.slf4j:slf4j-api 2.0.16
  • com.github.tomakehurst:wiremock-jre8 2.35.2
  • org.apache.logging.log4j:log4j-slf4j2-impl 2.23.1
tools/junit-openfeature/pom.xml
  • dev.openfeature:sdk [1.4,2.0)
  • org.apache.commons:commons-lang3 3.16.0
  • org.junit-pioneer:junit-pioneer 1.9.1
maven-wrapper
.mvn/wrapper/maven-wrapper.properties
  • maven 3.9.8

  • Check this box to trigger a request for Renovate to run again on this repository

Remove deprecated methods of flagd

Goal

Remove the methods annotated with @Deprecated in providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/FlagdProvider.java

Technical Details

With #294, several methods are deprecated because we moved to a builder pattern. We should remove them and the respective test code.

Dependencies

Activate Checkstyle rule to avoid star imports

The usage of Star imports within java is generally seen as a bad practice as it leads to tight coupling between packages and might lead to problems when a new version of a library introduces name clashes. see https://checkstyle.sourceforge.io/version/4.4/5.x/config_imports.html - as we do have a tool in place which can prevent the usage, we should activate the rule

<module name="AvoidStarImport">
</module>

see the already raised nit in a pull request #810 (comment)

wdyt?

Add automatic module names to all packages

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.

[FEATURE] Change fractional custom op from percentage-based to relative weighting.

Requirements

Currently, the fractional operator in the in-process provider is percentage-based; meaning you must specify the relative distribution of the variants in terms of a percentage. Consistent with flagd, we should change this instead to be a relative weight, meaning that the integers do not need to sum to 100. For example, this fractional:

"fractional": [
          [
            "red",
            25
          ],
          [
            "blue",
            25
          ],
          [
            "green",
            25
          ],
          [
            "grey",
            25
          ]
        ]

Would remain valid, but could also be expressed as:

"fractional": [
          [
            "red",
            1
          ],
          [
            "blue",
            1
          ],
          [
            "green",
            1
          ],
          [
            "grey",
            1
          ]
        ]

See issue and PR in Go/flagd.

Add OTel Hook

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:

  • in the 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)
  • in the error stage, records the exception

In 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);
  }
}

See: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/feature-flags.md

[flagd-provider] add unit test for zero-value resolutions from 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:

  • manual test confirming zero values are returned from the flagd provider when they are missing from the gRPC message (boolean set to false or numeric set to 0 in flagd config)
  • new tests that assert correct values for zero-value flags

see: open-feature/flagd#218

[flagd] Include scope as flag evaluation metadata

flagd 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.

Footnotes

  1. https://github.com/open-feature/flagd/blob/main/core/pkg/evaluator/json.go#L305-L308^

  2. https://flagd.dev/reference/sync-configuration/#source-configuration

[flagd provider] align with configuration in JS and go version, add env support

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.

[flagd] Add `$flagd.timestamp` to in-process evalutor

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.

[flagd] NPE with null valued contexts

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

[flagd-provider] fix non-conformant config options

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:

  • update the flagd provider to default to 0 (infinite) retries
  • verify other defaults

[env-var-provider] Suppot keys transformation

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.