Skip to content

Conversation

@sameerank
Copy link

@sameerank sameerank commented Oct 24, 2025

What does this PR do?

Motivation:

Change log entry

None because this binding is an internal feature (not user-facing). User-facing methods will be from the OpenFeature provider

Additional Notes:

Since datadog-ffe-ffi (DataDog/libdatadog#1282) hasn't been published yet, you'll need to build libdatadog locally to access the evaluation engine.

Prerequisites

  • Rust toolchain with cargo and cbindgen
  • Ruby development environment
  • pkg-config system tool
  • Datadog repositories cloned under ~/dd/ (assumes you have ~/dd/dd-trace-rb and ~/dd/libdatadog)
To build libdatadog and test binding in dd-trace-rb

Run this script.

zsh setup_ffe.sh
To clean and retry
cd ~/dd/dd-trace-rb
rm -rf tmp/ my-libdatadog-build/
rm -f lib/*.bundle
bundle exec rake clean
# Then repeat

How to test the change?

Implements Ruby integration for Feature Flagging & Experimentation (FFE) following ddsketch patterns:

- Add native C extension wrapper (ext/libdatadog_api/feature_flags.c)
- Create Ruby API with graceful degradation (lib/datadog/core/feature_flags.rb)
- Add type signatures and test suite
- Register FFE classes in libdatadog_api init
@github-actions github-actions bot added the core Involves Datadog core libraries label Oct 24, 2025
@github-actions
Copy link

github-actions bot commented Oct 24, 2025

Thank you for updating Change log entry section 👏

Visited at: 2025-10-24 15:17:34 UTC

@github-actions
Copy link

github-actions bot commented Oct 24, 2025

Typing analysis

Note: Ignored files are excluded from the next sections.

Untyped methods

This PR introduces 1 untyped method. It increases the percentage of typed methods from 51.13% to 51.29% (+0.16%).

Untyped methods (+1-0)Introduced:
sig/datadog/core/feature_flags.rbs:38
└── def initialize: () -> void

If you believe a method or an attribute is rightfully untyped or partially typed, you can add # untyped:accept to the end of the line to remove it from the stats.

@datadog-official
Copy link

datadog-official bot commented Oct 24, 2025

⚠️ Tests

⚠️ Warnings

🧪 10 Tests failed

Datadog::Core::FeatureFlags.supported? when feature flags are supported returns true from rspec (Datadog)
expected true
     got false

Failure/Error: expect(described_class.supported?).to be true

  expected true
       got false
./spec/datadog/core/feature_flags_spec.rb:48:in 'block (4 levels) in <top (required)>'
./spec/spec_helper.rb:272:in 'block (2 levels) in <top (required)>'
./spec/spec_helper.rb:154:in 'block (2 levels) in <top (required)>'
...
Datadog::Core::FeatureFlags when Feature Flags are supported Datadog::Core::FeatureFlags::EvaluationContext.new_with_attribute creates an evaluation context with attribute from rspec (Datadog)
expected no Exception, got #<ArgumentError: Feature Flags are not supported: cannot load such file -- libdatadog_api.3.4_x86_64-linux> with backtrace:
  # ./lib/datadog/core/feature_flags.rb:37:in 'Datadog::Core::FeatureFlags::EvaluationContext.new_with_attribute'
  # ./spec/datadog/core/feature_flags_spec.rb:138:in 'block (5 levels) in <top (required)>'
  # ./spec/datadog/core/feature_flags_spec.rb:142:in 'block (6 levels) in <top (required)>'
  # ./spec/datadog/core/feature_flags_spec.rb:142:in 'block (5 levels) in <top (required)>'
  # ./spec/spec_helper.rb:272:in 'block (2 levels) in <top (required)>'
  # ./spec/spec_helper.rb:154:in 'block (2 levels) in <top (required)>'
  # /usr/local/bundle/gems/webmock-3.26.0/lib/webmock/rspec.rb:39:in 'block (2 levels) in <top (required)>'
  # /usr/local/bundle/gems/rspec-wait-0.0.10/lib/rspec/wait.rb:47:in 'block (2 levels) in <top (required)>'
  # ./spec/support/execute_in_fork.rb:32:in 'ForkableExample#run'
...
Datadog::Core::FeatureFlags when Feature Flags are supported .get_assignment with existing flag returns an Assignment object from rspec (Datadog)
Feature Flags are not supported: cannot load such file -- libdatadog_api.3.4_x86_64-linux

Failure/Error: raise(ArgumentError, "Feature Flags are not supported: #{Datadog::Core::LIBDATADOG_API_FAILURE}")

ArgumentError:
  Feature Flags are not supported: cannot load such file -- libdatadog_api.3.4_x86_64-linux
./lib/datadog/core/feature_flags.rb:18:in 'Datadog::Core::FeatureFlags::Configuration#initialize'
./spec/datadog/core/feature_flags_spec.rb:106:in 'Class#new'
./spec/datadog/core/feature_flags_spec.rb:106:in 'block (3 levels) in <top (required)>'
./spec/datadog/core/feature_flags_spec.rb:148:in 'block (4 levels) in <top (required)>'
...
View all

ℹ️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 45a77a0 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

- Updated method names in the C extension and Ruby bindings to include a "_native_" prefix for clarity.
- Adjusted initialization methods in the Ruby API to call the renamed native methods.
- Removed unnecessary initialization in the Assignment class, as it is now created via the native get_assignment method.
- Updated feature flag configuration structure in tests to align with recent changes.
- Integrated crashtracker, process discovery, library configuration, and ddsketch initialization into the core module.
- Add custom build detection to extconf.rb to support platforms without prebuilt libdatadog gem binaries
- Include missing headers (common.h, library-config.h) in datadog_ruby_common.h for FFE type definitions
- Update setup_ffe.sh to compile Ruby extension with proper cleanup of build artifacts
- Skip problematic RSpec tests that have isolation issues in fork environment (functionality works correctly)
- Add complete build directory cleanup to setup script
- Fixed ddog_ffe_evaluation_context_new_with_attributes to use AttributePair struct
@sameerank
Copy link
Author

Closing this PR in favor of #5007

@sameerank sameerank closed this Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Involves Datadog core libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants