Skip to content

Commit 06e6e46

Browse files
feat(load-generator): Adapt OpenFeature OFREP instead of IN_PROCESS (#2114)
* feat(load-generator): Adapt OpenFeature OFREP instead of IN_PROCESS OpenFeature supports multiple different modes. The newest implementation relies on threads and other python internal, which seem to be monkeypatched by locust. Due to this, the IN_PROCESS mode is not working properly anymore and is causing issues. Instead we suggest to switch to the OFREP (OpenFeature Remote Evaluation Protocol) for this usecase. This is a simple http call which will return all evaluate flags, and will regularly poll for changes. Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com> * Add ports to docker-compose.minimal * fixup: add missing envvar for the ofrepport to the loadgenerator Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com> * Add FLAGD_OFREP_PORT to docker compose minimal --------- Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com> Co-authored-by: Juliano Costa <juliano.costa@datadoghq.com> Co-authored-by: Juliano Costa <julianocosta89@outlook.com>
1 parent ae753db commit 06e6e46

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

.env

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ SHIPPING_DOCKERFILE=./src/shipping/Dockerfile
133133
# Flagd
134134
FLAGD_HOST=flagd
135135
FLAGD_PORT=8013
136+
FLAGD_OFREP_PORT=8016
136137

137138
# Flagd UI
138139
FLAGD_UI_HOST=flagd-ui

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ the release.
1212
* [quote] Updated open-telemetry/exporter-otlp to 1.2.1 which includes the
1313
fix for `IS_REMOTE` flag feature
1414
([#2112](https://github.com/open-telemetry/opentelemetry-demo/pull/2112))
15+
* [load-generator] Change OpenFeature Evaluation to Remote Evaluation Protocol,
16+
based on [this issue in OpenFeature/python-sdk-contrib](https://github.com/open-feature/python-sdk-contrib/issues/198)
17+
([#2114](https://github.com/open-telemetry/opentelemetry-demo/pull/2114))
1518

1619
## 2.0.1
1720

docker-compose.minimal.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ services:
345345
- PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
346346
- LOCUST_WEB_HOST=0.0.0.0
347347
- FLAGD_HOST
348-
- FLAGD_PORT
348+
- FLAGD_OFREP_PORT
349349
depends_on:
350350
frontend:
351351
condition: service_started
@@ -522,7 +522,8 @@ services:
522522
"file:./etc/flagd/demo.flagd.json"
523523
]
524524
ports:
525-
- 8013
525+
- "${FLAGD_PORT}"
526+
- "${FLAGD_OFREP_PORT}"
526527
volumes:
527528
- ./src/flagd:/etc/flagd
528529
logging:

docker-compose.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ services:
421421
- PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
422422
- LOCUST_WEB_HOST=0.0.0.0
423423
- FLAGD_HOST
424-
- FLAGD_PORT
424+
- FLAGD_OFREP_PORT
425425
depends_on:
426426
frontend:
427427
condition: service_started
@@ -608,7 +608,8 @@ services:
608608
"file:./etc/flagd/demo.flagd.json"
609609
]
610610
ports:
611-
- 8013
611+
- "${FLAGD_PORT}"
612+
- "${FLAGD_OFREP_PORT}"
612613
volumes:
613614
- ./src/flagd:/etc/flagd
614615
logging:

src/load-generator/locustfile.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from opentelemetry.sdk.resources import Resource
3535

3636
from openfeature import api
37-
from openfeature.contrib.provider.flagd import FlagdProvider
37+
from openfeature.contrib.provider.ofrep import OFREPProvider
3838
from openfeature.contrib.hook.opentelemetry import TracingHook
3939

4040
from playwright.async_api import Route, Request
@@ -69,7 +69,8 @@
6969
logging.info("Instrumentation complete")
7070

7171
# Initialize Flagd provider
72-
api.set_provider(FlagdProvider(host=os.environ.get('FLAGD_HOST', 'flagd'), port=os.environ.get('FLAGD_PORT', 8013)))
72+
base_url = f"http://{os.environ.get('FLAGD_HOST', 'localhost')}:{os.environ.get('FLAGD_OFREP_PORT', 8016)}"
73+
api.set_provider(OFREPProvider(base_url=base_url))
7374
api.add_hooks([TracingHook()])
7475

7576
def get_flagd_value(FlagName):

src/load-generator/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ opentelemetry-sdk==1.30.0
3131
opentelemetry-semantic-conventions==0.51b0
3232
opentelemetry-util-http==0.51b0
3333
openfeature-sdk==0.8.0
34-
openfeature-provider-flagd==0.1.5
34+
openfeature-provider-ofrep==0.1.1
3535
openfeature-hooks-opentelemetry==0.2.0
3636
protobuf==5.29.3
3737
psutil==6.1.1

0 commit comments

Comments
 (0)