Repository navigation
test(ffe): enable .NET agentless configuration source #7496
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
Merged
gh-worker-dd-mergequeue-cf854d
merged 11 commits into
main
from
pavlo.khrebto/FFL-2703/dotnet-agentless-configuration
Sep 28, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
00aa4b2
test(ffe): enable .NET agentless configuration source
pavlokhrebto a5f255a
[FeatureFlags] Trigger system-tests base image build
pavlokhrebto 1defabe
Merge branch 'main' of github.com:DataDog/system-tests into pavlo.khr…
pavlokhrebto 8cba818
test(ffe): await SetProviderAsync and require dotnet 3.54.0
pavlokhrebto 1f992d7
test(ffe): fix the dotnet parametric FFE endpoints against OpenFeatur…
pavlokhrebto 5a64d4d
Merge branch 'main' of github.com:DataDog/system-tests into pavlo.khr…
pavlokhrebto 5fe83f9
test(ffe): mark dotnet cold-start cases as bug until FFL-3325 ships
pavlokhrebto 29010b9
test(ffe): use long-key form for the dotnet cold-start manifest entries
pavlokhrebto 4657f3b
Merge main into .NET agentless configuration tests
leoromanovsky 03c4320
test(ffe): address review on the dotnet parametric FFE endpoints
pavlokhrebto ac712c1
Merge branch 'pavlo.khrebto/FFL-2703/dotnet-agentless-configuration' …
pavlokhrebto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
utils/build/docker/dotnet/parametric/Endpoints/FfeTestApi.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| using System.ComponentModel; | ||
| using System.Reflection; | ||
| using System.Text.Json; | ||
| using OpenFeature; | ||
| using OpenFeature.Constant; | ||
| using OpenFeature.Model; | ||
|
|
||
| namespace ApmTestApi.Endpoints; | ||
|
|
||
| public abstract class FfeTestApi | ||
| { | ||
| private static FeatureClient? _client; | ||
| private static ILogger? _logger; | ||
|
|
||
| public static void MapFfeEndpoints(WebApplication app, ILogger logger) | ||
| { | ||
| _logger = logger; | ||
|
|
||
| app.MapPost("/ffe/start", StartFfe); | ||
| app.MapPost("/ffe/evaluate", EvaluateFfe); | ||
| } | ||
|
|
||
| private static async Task<IResult> StartFfe() | ||
| { | ||
| try | ||
| { | ||
| _logger?.LogInformation("Initializing FFE provider"); | ||
|
|
||
| var provider = new Datadog.FeatureFlags.OpenFeature.DatadogProvider(); | ||
|
|
||
| // Only the async call runs InitializeAsync, which waits for the first configuration. | ||
| await Api.Instance.SetProviderAsync(provider); | ||
| _client = Api.Instance.GetClient(); | ||
|
|
||
| return Results.Ok(); | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| _logger?.LogError(e, "Error starting FFE provider"); | ||
| return Results.Json(new { error = e.Message }, statusCode: 500); | ||
| } | ||
| } | ||
|
|
||
| private static async Task<IResult> EvaluateFfe(EvaluateRequest request) | ||
| { | ||
| if (_client is null) | ||
| { | ||
| return Results.Json(new { error = "FFE provider not initialized" }, statusCode: 500); | ||
| } | ||
|
|
||
| var contextBuilder = EvaluationContext.Builder().SetTargetingKey(request.TargetingKey); | ||
|
|
||
| foreach (var (key, attribute) in request.Attributes ?? new()) | ||
| { | ||
| switch (attribute.ValueKind) | ||
| { | ||
| case JsonValueKind.String: | ||
| contextBuilder.Set(key, attribute.GetString()!); | ||
| break; | ||
| case JsonValueKind.Number: | ||
| contextBuilder.Set(key, attribute.GetDouble()); | ||
| break; | ||
| case JsonValueKind.True: | ||
| case JsonValueKind.False: | ||
| contextBuilder.Set(key, attribute.GetBoolean()); | ||
| break; | ||
| default: | ||
| contextBuilder.Set(key, attribute.GetRawText()); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| var context = contextBuilder.Build(); | ||
| var defaultValue = request.DefaultValue; | ||
|
|
||
| try | ||
| { | ||
| return request.VariationType switch | ||
| { | ||
| "BOOLEAN" => ToResult(await _client.GetBooleanDetailsAsync(request.Flag, defaultValue.GetBoolean(), context)), | ||
| "STRING" => ToResult(await _client.GetStringDetailsAsync(request.Flag, defaultValue.GetString()!, context)), | ||
| "INTEGER" => ToResult(await _client.GetIntegerDetailsAsync(request.Flag, defaultValue.GetInt32(), context)), | ||
| "NUMERIC" => ToResult(await _client.GetDoubleDetailsAsync(request.Flag, defaultValue.GetDouble(), context)), | ||
| "JSON" => ToResult(await _client.GetObjectDetailsAsync(request.Flag, new Value(defaultValue.GetRawText()), context)), | ||
| _ => Results.Ok(new { value = defaultValue, reason = "DEFAULT", errorCode = (string?)null }), | ||
| }; | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| _logger?.LogError(e, "Error evaluating flag"); | ||
| return Results.Ok(new { value = defaultValue, reason = "ERROR", errorCode = (string?)null }); | ||
| } | ||
| } | ||
|
|
||
| private static IResult ToResult<T>(FlagEvaluationDetails<T> details) | ||
| => Results.Ok(new { value = details.Value, reason = details.Reason ?? "DEFAULT", errorCode = ToErrorCode(details.ErrorType) }); | ||
|
|
||
| // OpenFeature carries the spec error code on each ErrorType member as its Description. | ||
| private static string? ToErrorCode(ErrorType errorType) | ||
| => errorType == ErrorType.None | ||
| ? null | ||
| : typeof(ErrorType).GetField(errorType.ToString())?.GetCustomAttribute<DescriptionAttribute>()?.Description; | ||
|
|
||
| public sealed record EvaluateRequest( | ||
| string Flag, | ||
| string VariationType, | ||
| JsonElement DefaultValue, | ||
| string TargetingKey, | ||
| Dictionary<string, JsonElement>? Attributes); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.