Skip to content

Commit

Permalink
Adding empty span.
Browse files Browse the repository at this point in the history
Signed-off-by: André Silva <[email protected]>
  • Loading branch information
askpt committed Dec 31, 2024
1 parent 703f418 commit 729bd65
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/OpenFeature.Tests/Hooks/TracingHookTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ await tracingHook.AfterAsync(ctx,
Assert.Contains(new KeyValuePair<string, object?>("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<string>("my-flag", "foo", Constant.FlagValueType.String,
new ClientMetadata("my-client", "1.0"), new Metadata("my-provider"), evaluationContext);

// Act
await tracingHook.AfterAsync(ctx,

Check failure on line 85 in test/OpenFeature.Tests/Hooks/TracingHookTests.cs

View workflow job for this annotation

GitHub Actions / check-format

Consider calling ConfigureAwait on the awaited task
new FlagEvaluationDetails<string>("my-flag", "foo", Constant.ErrorType.None, "STATIC", "default"),
new Dictionary<string, object>());

this._tracerProvider.ForceFlush();

// Assert
Assert.Empty(this._exportedItems);
}

[Fact]
public async Task TestError()
{
Expand Down Expand Up @@ -100,4 +120,23 @@ public async Task TestError()

Assert.Contains(new KeyValuePair<string, object?>("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<string>("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"),

Check failure on line 134 in test/OpenFeature.Tests/Hooks/TracingHookTests.cs

View workflow job for this annotation

GitHub Actions / check-format

Consider calling ConfigureAwait on the awaited task
new Dictionary<string, object>());

this._tracerProvider.ForceFlush();

// Assert
Assert.Empty(this._exportedItems);
}
}

0 comments on commit 729bd65

Please sign in to comment.