From 854f8519ac89d5f25f8ee13ec3b93981eff5e2d3 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Wed, 17 Aug 2022 13:42:56 -0400 Subject: [PATCH 1/9] add feature flags on start --- .../lib/featureflagservice/release.ex | 5 +++++ .../20220524172636_create_featureflags.exs | 21 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/featureflagservice/lib/featureflagservice/release.ex b/src/featureflagservice/lib/featureflagservice/release.ex index 9adad2960e..f50d613118 100644 --- a/src/featureflagservice/lib/featureflagservice/release.ex +++ b/src/featureflagservice/lib/featureflagservice/release.ex @@ -8,6 +8,11 @@ defmodule Featureflagservice.Release do def migrate do load_app() + # Migrations don't always run on startup because the Postgres database may not be completely ready + # TODO: check for database connection instead of 5 second sleep + IO.puts "Waiting 5 seconds for database to start..." + Process.sleep(5000) + for repo <- repos() do {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true)) end diff --git a/src/featureflagservice/priv/repo/migrations/20220524172636_create_featureflags.exs b/src/featureflagservice/priv/repo/migrations/20220524172636_create_featureflags.exs index 4d1f61ebad..eeea5ceef0 100644 --- a/src/featureflagservice/priv/repo/migrations/20220524172636_create_featureflags.exs +++ b/src/featureflagservice/priv/repo/migrations/20220524172636_create_featureflags.exs @@ -11,5 +11,24 @@ defmodule Featureflagservice.Repo.Migrations.CreateFeatureflags do end create unique_index(:featureflags, [:name]) + + execute(&execute_up/0, &execute_down/0) + end + + defp execute_up do + repo().insert(%Featureflagservice.FeatureFlags.FeatureFlag{ + name: "productCatalogFailure", + description: "Fail product catalog service on a specific product", + enabled: false}) + + repo().insert(%Featureflagservice.FeatureFlags.FeatureFlag{ + name: "shippingFailure", + description: "Fail shipping service when shipping a product to a non-USA address", + enabled: false}) + end + + defp execute_down do + repo().delete(%Featureflagservice.FeatureFlags.FeatureFlag{name: "productCatalogFailure"}) + repo().delete(%Featureflagservice.FeatureFlags.FeatureFlag{name: "shippingFailure"}) end -end +end \ No newline at end of file From 3b8af77e423579f198b33f9d20f63919bda3a180 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Wed, 17 Aug 2022 16:40:24 -0400 Subject: [PATCH 2/9] revert sleep change --- src/featureflagservice/lib/featureflagservice/release.ex | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/featureflagservice/lib/featureflagservice/release.ex b/src/featureflagservice/lib/featureflagservice/release.ex index f50d613118..9adad2960e 100644 --- a/src/featureflagservice/lib/featureflagservice/release.ex +++ b/src/featureflagservice/lib/featureflagservice/release.ex @@ -8,11 +8,6 @@ defmodule Featureflagservice.Release do def migrate do load_app() - # Migrations don't always run on startup because the Postgres database may not be completely ready - # TODO: check for database connection instead of 5 second sleep - IO.puts "Waiting 5 seconds for database to start..." - Process.sleep(5000) - for repo <- repos() do {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true)) end From c975f5dc24f7ad776b3eb1d399a5a85596183130 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Wed, 17 Aug 2022 16:53:57 -0400 Subject: [PATCH 3/9] document feature flags --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index cd063c14d1..aa8620c70f 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,18 @@ Once the images are built and containers are started you can access: - Grafana: - Feature Flags UI: +#### Enable Feature Flags + +This demo comes with 2 feature flags which control failure conditions in the +Product Catalog and Shipping services. By default the flags are disabled. Using +the Feature Flags UI you will be able to control the +status of these feature flags. + +| Feature Flag | Description | +|-------------------------|---------------------------------------------------------------------------| +| `productCatalogFailure` | Generate an error for `GetProduct` requests with product id: `OLJCESPC7Z` | +| `shippingFailure` | Induce very long latency when shipping outside of USA | + #### Bring your own backend Likely you want to use the Webstore as a demo application for an observability From 5e4cda716ca94dad52084eb606562393d2aeb5f1 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Wed, 17 Aug 2022 16:56:51 -0400 Subject: [PATCH 4/9] feature flag definitions --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa92cd0745..f3b5beb927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,3 +75,5 @@ significant modifications will be credited to OpenTelemetry Authors. ([#245](https://github.com/open-telemetry/opentelemetry-demo/pull/245)) * Added Frontend Instrumentation ([#293](https://github.com/open-telemetry/opentelemetry-demo/pull/293)) +* Add Feature Flags definitions +([#314](https://github.com/open-telemetry/opentelemetry-demo/pull/314)) From a693865ee0ee0c7db56e998e817d27aa929857e3 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Wed, 17 Aug 2022 17:04:33 -0400 Subject: [PATCH 5/9] Revert "document feature flags" This reverts commit c975f5dc24f7ad776b3eb1d399a5a85596183130. --- README.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/README.md b/README.md index aa8620c70f..cd063c14d1 100644 --- a/README.md +++ b/README.md @@ -58,18 +58,6 @@ Once the images are built and containers are started you can access: - Grafana: - Feature Flags UI: -#### Enable Feature Flags - -This demo comes with 2 feature flags which control failure conditions in the -Product Catalog and Shipping services. By default the flags are disabled. Using -the Feature Flags UI you will be able to control the -status of these feature flags. - -| Feature Flag | Description | -|-------------------------|---------------------------------------------------------------------------| -| `productCatalogFailure` | Generate an error for `GetProduct` requests with product id: `OLJCESPC7Z` | -| `shippingFailure` | Induce very long latency when shipping outside of USA | - #### Bring your own backend Likely you want to use the Webstore as a demo application for an observability From 466b2861da73826af46e9f20ce9a0015396f3259 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Wed, 17 Aug 2022 17:07:42 -0400 Subject: [PATCH 6/9] document feature flags --- docs/feature_flags.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 docs/feature_flags.md diff --git a/docs/feature_flags.md b/docs/feature_flags.md new file mode 100644 index 0000000000..ea4ec7e7f7 --- /dev/null +++ b/docs/feature_flags.md @@ -0,0 +1,11 @@ +# Feature Flags + +This demo comes with 2 feature flags which control failure conditions in the +Product Catalog and Shipping services. By default the flags are disabled. Using +the Feature Flags UI you will be able to control the +status of these feature flags. + +| Feature Flag | Service(s) | Description | +|-------------------------|-----------------|---------------------------------------------------------------------------| +| `productCatalogFailure` | Product Catalog | Generate an error for `GetProduct` requests with product id: `OLJCESPC7Z` | +| `shippingFailure` | Shipping | Induce very long latency when shipping outside of USA | From 7269f5f98a681bd1c0c103e1880fc5bff8fd7e55 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Wed, 17 Aug 2022 17:11:05 -0400 Subject: [PATCH 7/9] document feature flags --- docs/feature_flags.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/feature_flags.md b/docs/feature_flags.md index ea4ec7e7f7..a40ca27809 100644 --- a/docs/feature_flags.md +++ b/docs/feature_flags.md @@ -8,4 +8,4 @@ status of these feature flags. | Feature Flag | Service(s) | Description | |-------------------------|-----------------|---------------------------------------------------------------------------| | `productCatalogFailure` | Product Catalog | Generate an error for `GetProduct` requests with product id: `OLJCESPC7Z` | -| `shippingFailure` | Shipping | Induce very long latency when shipping outside of USA | +| `shippingFailure` | Shipping | Induce very long latency when shipping outside of USA | From c524ba11822614f4998072138ef283ef06da6e56 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Wed, 17 Aug 2022 17:19:14 -0400 Subject: [PATCH 8/9] add reference to feature flags --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 80b058bb28..2581227e9d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ This repo is a work in progress. If you'd like to help, check out our ## Documentation - [Demo Screenshots](./docs/demo_screenshots.md) +- [Feature Flags](./docs/feature_flags.md) - [Manual Span Attributes](./docs/manual_span_attributes.md) - [Metric Feature Coverage by Service](./docs/metric_service_features.md) - [Requirements](./docs/requirements/README.md) From 97f7a580d184af71f0cae6c8b219164430fbed0f Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Thu, 18 Aug 2022 11:19:42 -0400 Subject: [PATCH 9/9] fix nits --- docs/feature_flags.md | 8 ++++---- .../migrations/20220524172636_create_featureflags.exs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/feature_flags.md b/docs/feature_flags.md index a40ca27809..9254c02b68 100644 --- a/docs/feature_flags.md +++ b/docs/feature_flags.md @@ -1,9 +1,9 @@ # Feature Flags -This demo comes with 2 feature flags which control failure conditions in the -Product Catalog and Shipping services. By default the flags are disabled. Using -the Feature Flags UI you will be able to control the -status of these feature flags. +This demo comes with several feature flags which can control failure conditions +in specific services. By default the flags are disabled. Using the Feature Flags +UI you will be able to control the status of these +feature flags. | Feature Flag | Service(s) | Description | |-------------------------|-----------------|---------------------------------------------------------------------------| diff --git a/src/featureflagservice/priv/repo/migrations/20220524172636_create_featureflags.exs b/src/featureflagservice/priv/repo/migrations/20220524172636_create_featureflags.exs index eeea5ceef0..61dee0c5ed 100644 --- a/src/featureflagservice/priv/repo/migrations/20220524172636_create_featureflags.exs +++ b/src/featureflagservice/priv/repo/migrations/20220524172636_create_featureflags.exs @@ -31,4 +31,4 @@ defmodule Featureflagservice.Repo.Migrations.CreateFeatureflags do repo().delete(%Featureflagservice.FeatureFlags.FeatureFlag{name: "productCatalogFailure"}) repo().delete(%Featureflagservice.FeatureFlags.FeatureFlag{name: "shippingFailure"}) end -end \ No newline at end of file +end