Skip to content

Commit

Permalink
Merge pull request open-telemetry#1 from joshleecreates/ffs.add_proba…
Browse files Browse the repository at this point in the history
…bility_based_flags

Add help text for float feature flags; Fix postgres upgrades
  • Loading branch information
puckpuck authored Dec 3, 2023
2 parents 4c3c438 + 5faad08 commit 729561a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
<%= error_tag f, :description %>

<%= label f, :enabled %>
<div style="font-size:smaller; margin:-5px 0 3px 0">
0 = false. 1 = true. Values between 0 and 1 are treated as a random probability.
</div>
<%= text_input f, :enabled %>
<%= number_input f, :enabled, min: 0, max: 1, step: 0.1, "aria-describedby": "enabled_help_text" %>
<p id="enabled_help_text">A value between 0.0 and 1.0. 0.0 is always disabled, 1.0 is always enabled, and all values between set a percentage chance on each request.</p>
<%= error_tag f, :enabled %>

<%= submit "Save" %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@


defmodule Featureflagservice.Repo.Migrations.CreateFeatureflags do
use Ecto.Migration

def change do
create table(:featureflags) do
add :name, :string
add :description, :string
add :enabled, :float, default: 0, null: false
add :enabled, :boolean, default: false, null: false

timestamps()
end
Expand All @@ -21,22 +19,26 @@ defmodule Featureflagservice.Repo.Migrations.CreateFeatureflags do
repo().insert(%Featureflagservice.FeatureFlags.FeatureFlag{
name: "productCatalogFailure",
description: "Fail product catalog service on a specific product",
enabled: 0.0})
enabled: false
})

repo().insert(%Featureflagservice.FeatureFlags.FeatureFlag{
name: "recommendationCache",
description: "Cache recommendations",
enabled: 0.0})
enabled: false
})

repo().insert(%Featureflagservice.FeatureFlags.FeatureFlag{
name: "adServiceFailure",
description: "Fail ad service requests sporadically",
enabled: 0.0})
enabled: false
})

repo().insert(%Featureflagservice.FeatureFlags.FeatureFlag{
name: "cartServiceFailure",
description: "Fail cart service requests sporadically",
enabled: 0.0})
enabled: false
})
end

defp execute_down do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defmodule Featureflagservice.Repo.Migrations.UpdateFeatureFlagsUseFloat do
use Ecto.Migration

def change do
"alter table featureflags alter enabled DROP DEFAULT,alter table featureflags alter enabled type numeric(2,1) using (case when enabled then 1.0 else 0.0 end), alter enabled set default '0.0';"
end
end

0 comments on commit 729561a

Please sign in to comment.