8000 feat: Add variation version to AI metric data by keelerm84 · Pull Request #71 · launchdarkly/dotnet-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Add variation version to AI metric data #71

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
merged 1 commit into from
Feb 6, 2025
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
7 changes: 7 additions & 0 deletions pkgs/sdk/server-ai/src/Config/LdAiConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ internal LdAiConfig(bool enabled, IEnumerable<Message> messages, Meta meta, Mode
model?.Custom ?? new Dictionary<string, LdValue>());
Messages = messages?.ToList() ?? new List<Message>();
VariationKey = meta?.VariationKey ?? "";
Version = meta?.Version ?? 1;
Enabled = enabled;
Provider = new ModelProvider(provider?.Name ?? "");
}
Expand All @@ -234,6 +235,7 @@ internal LdValue ToLdValue()
new Dictionary<string, LdValue>
{
{ "variationKey", LdValue.Of(VariationKey) },
{ "version", LdValue.Of(Version) },
{ "enabled", LdValue.Of(Enabled) }
}) },
{ "messages", LdValue.ArrayFrom(Messages.Select(m => LdValue.ObjectFrom(new Dictionary<string, LdValue>
Expand Down Expand Up @@ -271,6 +273,11 @@ internal LdValue ToLdValue()
/// </summary>
public string VariationKey { get; }

/// <summary>
/// This field meant for internal LaunchDarkly usage.
/// </summary>
public int Version { get; }

/// <summary>
/// Convenient helper that returns a disabled LdAiConfig.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions pkgs/sdk/server-ai/src/DataModel/DataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public class Meta
[JsonPropertyName("variationKey")]
public string VariationKey { get; set; }

/// <summary>
/// The variation version.
/// </summary>
[JsonPropertyName("version")]
public int? Version { get; set; }

/// <summary>
/// If the config is enabled.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions pkgs/sdk/server-ai/src/LdAiConfigTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public LdAiConfigTracker(ILaunchDarklyClient client, string configKey, LdAiConfi
_trackData = LdValue.ObjectFrom(new Dictionary<string, LdValue>
{
{ "variationKey", LdValue.Of(config.VariationKey)},
{ "version", LdValue.Of(config.Version)},
{ "configKey" , LdValue.Of(configKey ?? throw new ArgumentNullException(nameof(configKey))) }
});
}
Expand Down
10 changes: 10 additions & 0 deletions pkgs/sdk/server-ai/test/LdAiConfigTrackerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public void CanTrackDuration()
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
{
{ "variationKey", LdValue.Of(config.VariationKey) },
{ "version", LdValue.Of(config.Version) },
{ "configKey", LdValue.Of(flagKey) }
});
var tracker = new LdAiConfigTracker(mockClient.Object, flagKey, config, context);
Expand All @@ -61,6 +62,7 @@ public void CanTrackTimeToFirstToken()
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
{
{ "variationKey", LdValue.Of(config.VariationKey) },
{ "version", LdValue.Of(config.Version) },
{ "configKey", LdValue.Of(flagKey) }
});
var tracker = new LdAiConfigTracker(mockClient.Object, flagKey, config, context);
Expand All @@ -79,6 +81,7 @@ public void CanTrackSuccess()
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
{
{ "variationKey", LdValue.Of(config.VariationKey) },
{ "version", LdValue.Of(config.Version) },
{ "configKey", LdValue.Of(flagKey) }
});

Expand All @@ -99,6 +102,7 @@ public void CanTrackError()
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
{
{ "variationKey", LdValue.Of(config.VariationKey) },
{ "version", LdValue.Of(config.Version) },
{ "configKey", LdValue.Of(flagKey) }
});

Expand All @@ -119,6 +123,7 @@ public async void CanTrackDurationOfTask()
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
{
{ "variationKey", LdValue.Of(config.VariationKey) },
{ "version", LdValue.Of(config.Version) },
{ "configKey", LdValue.Of(flagKey) }
});

8000 Expand Down Expand Up @@ -153,6 +158,7 @@ public void CanTrackFeedback()
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
{
{ "variationKey", LdValue.Of(config.VariationKey) },
{ "version", LdValue.Of(config.Version) },
{ "configKey", LdValue.Of(flagKey) }
});

Expand All @@ -174,6 +180,7 @@ public void CanTrackTokens()
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
{
{ "variationKey", LdValue.Of(config.VariationKey) },
{ "version", LdValue.Of(config.Version) },
{ "configKey", LdValue.Of(flagKey) }
});

Expand Down Expand Up @@ -202,6 +209,7 @@ public void CanTrackResponseWithSpecificLatency()
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
{
{ "variationKey", LdValue.Of(config.VariationKey) },
{ "version", LdValue.Of(config.Version) },
{ "configKey", LdValue.Of(flagKey) }
});

Expand Down Expand Up @@ -245,6 +253,7 @@ public void CanTrackResponseWithPartialData()
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
{
{ "variationKey", LdValue.Of(config.VariationKey) },
{ "version", LdValue.Of(config.Version) },
{ "configKey", LdValue.Of(flagKey) }
});

Expand Down Expand Up @@ -279,6 +288,7 @@ public async Task CanTrackExceptionFromResponse()
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
{
{ "variationKey", LdValue.Of(config.VariationKey) },
{ "version", LdValue.Of(config.Version) },
{ "configKey", LdValue.Of(flagKey) }
});

Expand Down
Loading
0