From 729bd65f48903c0f42daf0bdd14aa177130410cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= <2493377+askpt@users.noreply.github.com> Date: Tue, 31 Dec 2024 11:18:42 +0000 Subject: [PATCH] Adding empty span. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com> --- .../Hooks/TracingHookTests.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/OpenFeature.Tests/Hooks/TracingHookTests.cs b/test/OpenFeature.Tests/Hooks/TracingHookTests.cs index 7e2caee9..485bc180 100644 --- a/test/OpenFeature.Tests/Hooks/TracingHookTests.cs +++ b/test/OpenFeature.Tests/Hooks/TracingHookTests.cs @@ -72,6 +72,26 @@ await tracingHook.AfterAsync(ctx, Assert.Contains(new KeyValuePair("feature_flag.provider_name", "my-provider"), ev.Tags); } + [Fact] + public async Task TestAfter_NoSpan() + { + // Arrange + var tracingHook = new TracingHook(); + var evaluationContext = EvaluationContext.Empty; + var ctx = new HookContext("my-flag", "foo", Constant.FlagValueType.String, + new ClientMetadata("my-client", "1.0"), new Metadata("my-provider"), evaluationContext); + + // Act + await tracingHook.AfterAsync(ctx, + new FlagEvaluationDetails("my-flag", "foo", Constant.ErrorType.None, "STATIC", "default"), + new Dictionary()); + + this._tracerProvider.ForceFlush(); + + // Assert + Assert.Empty(this._exportedItems); + } + [Fact] public async Task TestError() { @@ -100,4 +120,23 @@ public async Task TestError() Assert.Contains(new KeyValuePair("exception.message", "unexpected error"), ev.Tags); } + + [Fact] + public async Task TestError_NoSpan() + { + // Arrange + var tracingHook = new TracingHook(); + var evaluationContext = EvaluationContext.Empty; + var ctx = new HookContext("my-flag", "foo", Constant.FlagValueType.String, + new ClientMetadata("my-client", "1.0"), new Metadata("my-provider"), evaluationContext); + + // Act + await tracingHook.ErrorAsync(ctx, new Exception("unexpected error"), + new Dictionary()); + + this._tracerProvider.ForceFlush(); + + // Assert + Assert.Empty(this._exportedItems); + } }