Publish curated Knowledge Hub source from 2ed833f290b439a7bc91e5fd19b042c269e3bee9
This commit is contained in:
1 parent
10f2edcd29
commit
59f15b2d08
218 files changed
+23995
-1849
No files matched your search
@@ -0,0 +1,27 @@
|
||||
using System.Diagnostics.Metrics;
|
||||
using ItWorx.KnowledgeHub.Application.Operations;
|
||||
|
||||
namespace ItWorx.KnowledgeHub.IntegrationTests.Operations;
|
||||
|
||||
public sealed class PlatformMetricsTests
|
||||
{
|
||||
[Fact]
|
||||
public void Metrics_reject_unbounded_operation_and_outcome_dimensions()
|
||||
{
|
||||
var observed = new List<KeyValuePair<string, object?>>();
|
||||
using var listener = new MeterListener();
|
||||
listener.InstrumentPublished = (instrument, current) =>
|
||||
{
|
||||
if (instrument.Meter.Name == "ItWorx.KnowledgeHub.Platform") current.EnableMeasurementEvents(instrument);
|
||||
};
|
||||
listener.SetMeasurementEventCallback<double>((_, _, tags, _) => observed.AddRange(tags.ToArray()));
|
||||
listener.SetMeasurementEventCallback<long>((_, _, tags, _) => observed.AddRange(tags.ToArray()));
|
||||
listener.Start();
|
||||
using var metrics = new PlatformMetrics();
|
||||
metrics.Record("private query and bearer token", "secret", 0.1, 3);
|
||||
Assert.NotEmpty(observed);
|
||||
Assert.All(observed, tag => Assert.Contains(tag.Key, new[] { "operation", "outcome" }));
|
||||
Assert.DoesNotContain(observed, tag => tag.Value?.ToString()?.Contains("secret", StringComparison.Ordinal) == true);
|
||||
Assert.Contains(observed, tag => tag.Value?.ToString() == "other");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user