Skip to content
Open
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: 2 additions & 2 deletions manifests/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2059,7 +2059,7 @@ manifest:
- declaration: missing_feature (Not implemented)
component_version: <2.7.0
tests/docker_ssi/test_docker_ssi_servicenaming.py::TestDockerServiceNaming::test_service_name: missing_feature (No implemented)
tests/ffe/test_agentless_configuration.py: missing_feature (FFL-2701 tracks Ruby agentless configuration-source implementation; FFL-2731 tracks the system-tests contract)
tests/ffe/test_agentless_configuration.py: v2.44.0-dev
tests/ffe/test_dynamic_evaluation.py:
- weblog_declaration:
"*": irrelevant
Expand Down Expand Up @@ -2454,7 +2454,7 @@ manifest:
component_version: <2.40.0
tests/parametric/test_extract_behavior.py::Test_ExtractBehavior_Restart: incomplete_test_app (The parametric test app does not emit restart span links or preserve baggage)
tests/parametric/test_extract_behavior.py::Test_ExtractBehavior_Restart_With_Extract_First: incomplete_test_app (The parametric test app does not emit restart span links or preserve baggage)
tests/parametric/test_ffe/test_configuration_sources.py: missing_feature (FFL-2701 tracks Ruby agentless configuration-source implementation; FFL-2731 tracks system-tests configuration-source contract)
tests/parametric/test_ffe/test_configuration_sources.py: v2.44.0-dev
tests/parametric/test_ffe/test_dynamic_evaluation.py::Test_Feature_Flag_Dynamic_Evaluation: v2.23.0
tests/parametric/test_ffe/test_span_enrichment.py: missing_feature
tests/parametric/test_headers_b3.py::Test_Headers_B3::test_headers_b3_extract_invalid: # Easy win for all weblogs and version 2.27.0
Expand Down
41 changes: 20 additions & 21 deletions utils/build/docker/ruby/parametric/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,8 @@
c.logger.instance = Logger.new(STDOUT) # Make sure logs are available for inspection from outside the container.
end

if Datadog::Core::Remote.active_remote
# TODO: Remove this whole `if` condition if remote configuration is started by default.
if Datadog::Core::Remote.active_remote.started?
raise 'Remote Configuration worker already started! Remove this check and `Datadog::Core::Remote.active_remote.start` below.'
end

Datadog::Core::Remote.active_remote.start
end
remote = Datadog::Core::Remote.active_remote
remote&.start unless remote&.started?

def otel_tracer
OpenTelemetry.tracer_provider.tracer('otel-tracer')
Expand Down Expand Up @@ -842,22 +836,27 @@ def extract_http_headers(headers)
end
end

def handle_ffe_start(req, res)
OpenFeature::SDK.set_provider(Datadog::OpenFeature::Provider.new)
def handle_ffe_start(_req, res)
provider = Datadog::OpenFeature::Provider.new
feature_flagging_configured = %w[
DD_FEATURE_FLAGS_ENABLED
DD_FEATURE_FLAGS_CONFIGURATION_SOURCE
DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL
DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_POLL_INTERVAL_SECONDS
DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_REQUEST_TIMEOUT_SECONDS
DD_EXPERIMENTAL_FLAGGING_PROVIDER_ENABLED
DD_EXPERIMENTAL_FLAGGING_PROVIDER_INITIALIZATION_TIMEOUT_MS
].any? { |name| ENV.key?(name) }

# NOTE: There is no set_provider_and_wait in Ruby OpenFeature::SDK, but this is
# a subject to change.
#
# Remote Configuration will be received at this point because of the short
# polling delay.
10.times do
evaluator = Datadog::OpenFeature.engine.instance_variable_get(:@evaluator)
break unless evaluator.instance_variable_get(:@configuration).nil?

sleep 0.5
if feature_flagging_configured
OpenFeature::SDK.set_provider_and_wait(provider)
else
OpenFeature::SDK.set_provider(provider)
end

res.write({}.to_json)
rescue => e
res.status = 500
res.write({error: e.message}.to_json)
end

def handle_ffe_evaluation(req, res)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ class OpenFeatureController < ApplicationController
skip_before_action :verify_authenticity_token

def start
OpenFeature::SDK.set_provider(Datadog::OpenFeature::Provider.new)

# NOTE: There is no set_provider_and_wait in OpenFeature::SDK
loop do
break unless Datadog::OpenFeature.evaluator.ufc_json.nil?
sleep 0.1
end

OpenFeature::SDK.set_provider_and_wait(Datadog::OpenFeature::Provider.new)
render json: {}
rescue => e
render json: {error: e.message}, status: :internal_server_error
end

def evaluate
Expand Down
Loading