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
Original file line number Diff line number Diff line change
Expand Up @@ -425,29 +425,5 @@ public void GetNormalizedNumber_MatchesExpectedValue(string evaluationKey, strin
{
OctopusFeatureContext.GetNormalizedNumber(evaluationKey, targetingKey).Should().Be(expected);
}

[Fact]
public void WhenSameMissingSlug_IsEvaluatedRepeatedly_OnlyOneWarningIsLogged()
{
var featureToggles = new FeatureToggles([
new FeatureToggleEvaluation("known-feature", true, "evaluation-key", [], 100)
], []);
var fakeLogger = new FakeLogger();
var context = new OctopusFeatureContext(featureToggles, new SingleLoggerFactory(fakeLogger));

for (var i = 0; i < 10; i++)
{
context.Evaluate("missing-slug", defaultValue: false, context: null);
}

fakeLogger.Collector.GetSnapshot().Should().ContainSingle(r => r.Level == LogLevel.Warning);
}

class SingleLoggerFactory(ILogger logger) : ILoggerFactory
{
public ILogger CreateLogger(string categoryName) => logger;
public void AddProvider(ILoggerProvider provider) { }
public void Dispose() { }
}
}

9 changes: 0 additions & 9 deletions src/Octopus.OpenFeature.Provider/OctopusFeatureContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

namespace Octopus.OpenFeature.Provider;

partial class OctopusFeatureContext(FeatureToggles toggles, ILoggerFactory loggerFactory)

Check warning on line 11 in src/Octopus.OpenFeature.Provider/OctopusFeatureContext.cs

View workflow job for this annotation

GitHub Actions / test-build-and-publish

Parameter 'loggerFactory' is unread.

Check warning on line 11 in src/Octopus.OpenFeature.Provider/OctopusFeatureContext.cs

View workflow job for this annotation

GitHub Actions / test-build-and-publish

Parameter 'loggerFactory' is unread.
{
public byte[] ContentHash => toggles.ContentHash;
readonly ILogger logger = loggerFactory.CreateLogger<OctopusFeatureContext>();
readonly ConcurrentDictionary<string, byte> warnedSlugs = new(StringComparer.OrdinalIgnoreCase);

public static OctopusFeatureContext Empty(ILoggerFactory loggerFactory)
{
Expand All @@ -30,13 +28,6 @@

if (feature == null)
{
if (warnedSlugs.TryAdd(slug, 0))
{
logger.LogWarning(
"The slug {Slug} did not match any of your Octopus Feature Toggles. Please double check your slug and try again.",
slug);
}

return new ResolutionDetails<bool>(slug, defaultValue, ErrorType.FlagNotFound,
"The slug provided did not match any of your Octopus Feature Toggles. Please double check your slug and try again.");
}
Expand Down
Loading