Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configure feature flag tracing for Python services #1553

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ the release.
([#1551](https://github.com/open-telemetry/opentelemetry-demo/pull/1551))
* [flagd] update to 0.10.1 and set 50M memory limit
([#1554](https://github.com/open-telemetry/opentelemetry-demo/pull/1554))
* [loadgenerator] Configure feature flag evaluation tracing
([#1553](https://github.com/open-telemetry/opentelemetry-demo/pull/1553))
* [recommendationservice] Configure feature flag evaluation tracing
([#1553](https://github.com/open-telemetry/opentelemetry-demo/pull/1553))

## 1.9.0

Expand Down
2 changes: 2 additions & 0 deletions src/loadgenerator/locustfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

from openfeature import api
from openfeature.contrib.provider.flagd import FlagdProvider
from openfeature.contrib.hook.opentelemetry import TracingHook

from playwright.async_api import Route, Request

Expand Down Expand Up @@ -69,6 +70,7 @@

# Initialize Flagd provider
api.set_provider(FlagdProvider(host=os.environ.get('FLAGD_HOST', 'flagd'), port=os.environ.get('FLAGD_PORT', 8013)))
api.set_hooks([TracingHook()])

def get_flagd_value(FlagName):
# Initialize OpenFeature
Expand Down
5 changes: 3 additions & 2 deletions src/loadgenerator/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ opentelemetry-proto==1.23.0
opentelemetry-sdk==1.23.0
opentelemetry-semantic-conventions==0.44b0
opentelemetry-util-http==0.44b0
openfeature-sdk==0.5.0
openfeature-provider-flagd==0.1.3
openfeature-sdk==0.7.0
openfeature-provider-flagd==0.1.5
openfeature-hooks-opentelemetry==0.1.3
protobuf==4.25.2
psutil==5.9.6
pyzmq==25.1.1
Expand Down
6 changes: 2 additions & 4 deletions src/recommendationservice/recommendation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
from openfeature import api
from openfeature.contrib.provider.flagd import FlagdProvider

# TODO: once openfeature otel hook for python is released, this will work
# from openfeature.contrib.hooks.otel import TracingHook
from openfeature.contrib.hook.opentelemetry import TracingHook

# Local
import logging
Expand Down Expand Up @@ -124,14 +123,13 @@ def must_map_env(key: str):
def check_feature_flag(flag_name: str):
# Initialize OpenFeature
client = api.get_client()
# TODO: once openfeature otel hook for python is released, this will work
# api.add_hooks(TracingHook())
return client.get_boolean_value("recommendationServiceCacheFailure", False)


if __name__ == "__main__":
service_name = must_map_env('OTEL_SERVICE_NAME')
api.set_provider(FlagdProvider(host=os.environ.get('FLAGD_HOST', 'flagd'), port=os.environ.get('FLAGD_PORT', 8013)))
api.add_hooks([TracingHook()])

# Initialize Traces and Metrics
tracer = trace.get_tracer_provider().get_tracer(service_name)
Expand Down
5 changes: 3 additions & 2 deletions src/recommendationservice/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ opentelemetry-distro==0.43b0
opentelemetry-exporter-otlp-proto-grpc==1.22.0
python-dotenv==1.0.0
python-json-logger==2.0.7
openfeature-sdk==0.5.0
openfeature-provider-flagd==0.1.3
openfeature-sdk==0.7.0
openfeature-provider-flagd==0.1.5
openfeature-hooks-opentelemetry==0.1.3
psutil==5.9.6 # Importing this will also import opentelemetry-instrumentation-system-metrics when running opentelemetry-bootstrap

Loading