Skip to content

Commit

Permalink
testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
Yun-Ting committed Oct 11, 2021
1 parent 30c6916 commit e2a3585
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,17 @@ public void MeterSourcesWildcardSupportMatchTest(bool hasView)
[Theory]
[InlineData(true)]
[InlineData(false)]
public void MeterSourcesWildcardSupportWithoutAddingMeterToProvider(bool hasView)
public void MeterSourcesWildcardSupportNegativeTestNoMeterAdded(bool hasView)
{
var meterNames = new[]
{
"AbcCompany.XyzProduct.ComponentA",
"abcCompany.xYzProduct.componentC",
};

using var meter1 = new Meter(meterNames[0]);
using var meter2 = new Meter(meterNames[1]);

var exportedItems = new List<Metric>();
var meterProviderBuilder = Sdk.CreateMeterProviderBuilder()
.AddInMemoryExporter(exportedItems);
Expand All @@ -244,6 +253,10 @@ public void MeterSourcesWildcardSupportWithoutAddingMeterToProvider(bool hasView

using var meterProvider = meterProviderBuilder.Build();
var measurement = new Measurement<int>(100, new("name", "apple"), new("color", "red"));

meter1.CreateObservableGauge("myGauge1", () => measurement);
meter2.CreateObservableGauge("myGauge2", () => measurement);

meterProvider.ForceFlush(MaxTimeToAllowForFlush);
Assert.True(exportedItems.Count == 0);
}
Expand Down

0 comments on commit e2a3585

Please sign in to comment.