Skip to content

Commit

Permalink
test: Make metric validation more consistent (#2840)
Browse files Browse the repository at this point in the history
  • Loading branch information
chynesNR authored Oct 21, 2024
1 parent a77919e commit ba9ee7b
Show file tree
Hide file tree
Showing 54 changed files with 219 additions and 219 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public static List<Metric> TryFindMetrics(ExpectedMetric expectedMetric, IEnumer
var foundMetrics = actualMetrics
.Where(actualMetric => (expectedMetric.IsRegexName && Regex.IsMatch(actualMetric.MetricSpec.Name, expectedMetric.metricName)) ||
(!expectedMetric.IsRegexName && expectedMetric.metricName == actualMetric.MetricSpec.Name))
.Where(actualMetric => (expectedMetric.IsRegexScope && Regex.IsMatch(actualMetric.MetricSpec.Scope, expectedMetric.metricScope)) ||
.Where(actualMetric => (expectedMetric.IsRegexScope && Regex.IsMatch(actualMetric.MetricSpec.Scope ?? string.Empty, expectedMetric.metricScope)) ||
(!expectedMetric.IsRegexScope && expectedMetric.metricScope == actualMetric.MetricSpec.Scope))
.ToList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public void Test()
var expectedMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"Supportability/MetricHarvest/transmit", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", callCount = 4 },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSent", callCount = 4 },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", CallCountAllHarvests = 4 },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSent", CallCountAllHarvests = 4 },
};

var metrics = _fixture.AgentLog.GetMetrics().ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void ExpectedMetrics()
{
new Assertions.ExpectedMetric(){ callCount = 1, metricName = "Supportability/ApiInvocation/TraceMetadata" },
new Assertions.ExpectedMetric(){ callCount = 1, metricName = "Supportability/ApiInvocation/GetLinkingMetadata"},
new Assertions.ExpectedMetric(){ callCount = 2, metricName = "Supportability/ApiInvocation/StartDatastoreSegment"}
new Assertions.ExpectedMetric(){ CallCountAllHarvests = 2, metricName = "Supportability/ApiInvocation/StartDatastoreSegment"}
};

var actualMetrics = Fixture.AgentLog.GetMetrics().ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ public void Test()

private readonly List<Assertions.ExpectedMetric> _generalMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"Supportability/ApiInvocation/CurrentTransaction", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/ApiInvocation/InsertDistributedTraceHeaders", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/ApiInvocation/CurrentTransaction", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/ApiInvocation/InsertDistributedTraceHeaders", CallCountAllHarvests = ExpectedTransactionCount },
};

private readonly List<Assertions.ExpectedMetric> _collectibleMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"DotNet/CollectibleController/AccessCollectible", callCount = 2 },
new Assertions.ExpectedMetric { metricName = @"DotNet/CollectibleController/AccessCollectible", metricScope = @"WebTransaction/MVC/Collectible/AccessCollectible", callCount = 2 },
new Assertions.ExpectedMetric { metricName = @"DotNet/CollectibleController/AccessCollectible", CallCountAllHarvests = 2 },
new Assertions.ExpectedMetric { metricName = @"DotNet/CollectibleController/AccessCollectible", metricScope = @"WebTransaction/MVC/Collectible/AccessCollectible", CallCountAllHarvests = 2 },
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ public void Test()
private readonly List<Assertions.ExpectedMetric> _generalMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"Supportability/OS/Linux", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsCollected", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsCollected", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Apdex"},
new Assertions.ExpectedMetric { metricName = @"ApdexAll"},
new Assertions.ExpectedMetric { metricName = @"HttpDispatcher", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransaction", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransactionTotalTime", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"HttpDispatcher", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransaction", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransactionTotalTime", CallCountAllHarvests = ExpectedTransactionCount },

new Assertions.ExpectedMetric { metricName = @"DotNet/Middleware Pipeline", callCount = ExpectedTransactionCount }
new Assertions.ExpectedMetric { metricName = @"DotNet/Middleware Pipeline", CallCountAllHarvests = ExpectedTransactionCount }
};

private readonly List<Assertions.ExpectedMetric> _indexMetrics = new List<Assertions.ExpectedMetric>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ public void Test()
private readonly List<Assertions.ExpectedMetric> _generalMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"Supportability/OS/Linux", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsCollected", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsCollected", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Apdex"},
new Assertions.ExpectedMetric { metricName = @"ApdexAll"},
new Assertions.ExpectedMetric { metricName = @"HttpDispatcher", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransaction", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransactionTotalTime", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"HttpDispatcher", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransaction", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransactionTotalTime", CallCountAllHarvests = ExpectedTransactionCount },

new Assertions.ExpectedMetric { metricName = @"DotNet/Middleware Pipeline", callCount = ExpectedTransactionCount }
new Assertions.ExpectedMetric { metricName = @"DotNet/Middleware Pipeline", CallCountAllHarvests = ExpectedTransactionCount }
};

private readonly List<Assertions.ExpectedMetric> _ioBoundNoSpecialAsyncMetrics = new List<Assertions.ExpectedMetric> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ public void Test()
private readonly List<Assertions.ExpectedMetric> _generalMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"Supportability/OS/Linux", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsCollected", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsCollected", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Apdex"},
new Assertions.ExpectedMetric { metricName = @"ApdexAll"},
new Assertions.ExpectedMetric { metricName = @"HttpDispatcher", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransaction", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransactionTotalTime", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"HttpDispatcher", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransaction", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransactionTotalTime", CallCountAllHarvests = ExpectedTransactionCount },

new Assertions.ExpectedMetric { metricName = @"DotNet/Middleware Pipeline", callCount = ExpectedTransactionCount }
new Assertions.ExpectedMetric { metricName = @"DotNet/Middleware Pipeline", CallCountAllHarvests = ExpectedTransactionCount }
};

private readonly List<Assertions.ExpectedMetric> _indexMetrics = new List<Assertions.ExpectedMetric>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public void Test()
{
var expectedMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"WebTransaction", callCount = 2 },
new Assertions.ExpectedMetric { metricName = @"WebTransactionTotalTime", callCount = 2 },
new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Values/Get", callCount = 2 },
new Assertions.ExpectedMetric { metricName = @"DotNet/Middleware Pipeline", callCount = 2 },
new Assertions.ExpectedMetric { metricName = @"DotNet/Middleware Pipeline", metricScope = @"WebTransaction/MVC/Values/Get", callCount = 2 },
new Assertions.ExpectedMetric { metricName = @"DotNet/ValuesController/Get", callCount = 2 },
new Assertions.ExpectedMetric { metricName = @"DotNet/ValuesController/Get", metricScope = @"WebTransaction/MVC/Values/Get", callCount = 2 },
new Assertions.ExpectedMetric { metricName = @"WebTransaction", CallCountAllHarvests = 2 },
new Assertions.ExpectedMetric { metricName = @"WebTransactionTotalTime", CallCountAllHarvests = 2 },
new Assertions.ExpectedMetric { metricName = @"WebTransaction/MVC/Values/Get", CallCountAllHarvests = 2 },
new Assertions.ExpectedMetric { metricName = @"DotNet/Middleware Pipeline", CallCountAllHarvests = 2 },
new Assertions.ExpectedMetric { metricName = @"DotNet/Middleware Pipeline", metricScope = @"WebTransaction/MVC/Values/Get", CallCountAllHarvests = 2 },
new Assertions.ExpectedMetric { metricName = @"DotNet/ValuesController/Get", CallCountAllHarvests = 2 },
new Assertions.ExpectedMetric { metricName = @"DotNet/ValuesController/Get", metricScope = @"WebTransaction/MVC/Values/Get", CallCountAllHarvests = 2 },
};

var metrics = _fixture.AgentLog.GetMetrics().ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ public void Test()

private readonly List<Assertions.ExpectedMetric> _generalMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsCollected", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsCollected", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Apdex"},
new Assertions.ExpectedMetric { metricName = @"ApdexAll"},
new Assertions.ExpectedMetric { metricName = @"HttpDispatcher", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransaction", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransactionTotalTime", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"HttpDispatcher", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransaction", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransactionTotalTime", CallCountAllHarvests = ExpectedTransactionCount },

new Assertions.ExpectedMetric { metricName = @"DotNet/Middleware Pipeline", callCount = ExpectedTransactionCount }
new Assertions.ExpectedMetric { metricName = @"DotNet/Middleware Pipeline", CallCountAllHarvests = ExpectedTransactionCount }
};

private readonly List<Assertions.ExpectedMetric> _ioBoundNoSpecialAsyncMetrics = new List<Assertions.ExpectedMetric> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ public void Test_SimpleInvocationMode()
var simpleTransactionName = "WebTransaction/AzureFunction/HttpTriggerFunctionUsingSimpleInvocation";
var simpleExpectedMetrics = new List<Assertions.ExpectedMetric>()
{
new() {metricName = "DotNet/HttpTriggerFunctionUsingSimpleInvocation", callCount = 2},
new() {metricName = "DotNet/HttpTriggerFunctionUsingSimpleInvocation", metricScope = simpleTransactionName, callCount = 2},
new() {metricName = simpleTransactionName, callCount = 2},
new() {metricName = "DotNet/HttpTriggerFunctionUsingSimpleInvocation", CallCountAllHarvests = 2},
new() {metricName = "DotNet/HttpTriggerFunctionUsingSimpleInvocation", metricScope = simpleTransactionName, CallCountAllHarvests = 2},
new() {metricName = simpleTransactionName, CallCountAllHarvests = 2},
};

var transactionSample = _fixture.AgentLog.TryGetTransactionSample(simpleTransactionName);
Expand Down Expand Up @@ -195,9 +195,9 @@ public void Test_PipelineMode()
var pipelineTransactionName = "WebTransaction/AzureFunction/HttpTriggerFunctionUsingAspNetCorePipeline";
var pipelineExpectedMetrics = new List<Assertions.ExpectedMetric>()
{
new() {metricName = "DotNet/HttpTriggerFunctionUsingAspNetCorePipeline", callCount = 2},
new() {metricName = "DotNet/HttpTriggerFunctionUsingAspNetCorePipeline", metricScope = pipelineTransactionName, callCount = 2},
new() {metricName = pipelineTransactionName, callCount = 2},
new() {metricName = "DotNet/HttpTriggerFunctionUsingAspNetCorePipeline", CallCountAllHarvests = 2},
new() {metricName = "DotNet/HttpTriggerFunctionUsingAspNetCorePipeline", metricScope = pipelineTransactionName, CallCountAllHarvests = 2},
new() {metricName = pipelineTransactionName, CallCountAllHarvests = 2},
};

var simpleTransactionName = "WebTransaction/AzureFunction/HttpTriggerFunctionUsingSimpleInvocation";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public void Test()
{
var expectedMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", callCount = 3 },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsCollected", callCount = 3 },
new Assertions.ExpectedMetric { metricName = @"HttpDispatcher", callCount = 3 },
new Assertions.ExpectedMetric { metricName = @"WebTransaction", callCount = 3 },
new Assertions.ExpectedMetric { metricName = @"WebTransactionTotalTime", callCount = 3 }
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", CallCountAllHarvests = 3 },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsCollected", CallCountAllHarvests = 3 },
new Assertions.ExpectedMetric { metricName = @"HttpDispatcher", CallCountAllHarvests = 3 },
new Assertions.ExpectedMetric { metricName = @"WebTransaction", CallCountAllHarvests = 3 },
new Assertions.ExpectedMetric { metricName = @"WebTransactionTotalTime", CallCountAllHarvests = 3 }
};

foreach (var webFormName in new List<string>() { "webform1.aspx", "webformslow.aspx"} )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public void Test()
{
var expectedMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric {metricName = @"DotNet/System.Web.Services.Protocols.SyncSessionlessHandler/ProcessRequest", callCount = 2 },
new Assertions.ExpectedMetric {metricName = @"DotNet/System.Web.Services.Protocols.SyncSessionlessHandler/ProcessRequest", metricScope = "WebTransaction/WebService/BasicWebService.TestWebService.HelloWorld", callCount = 2},
new Assertions.ExpectedMetric {metricName = @"WebTransaction/WebService/BasicWebService.TestWebService.HelloWorld", callCount = 2},
new Assertions.ExpectedMetric {metricName = @"DotNet/BasicWebService.TestWebService.HelloWorld", callCount = 2},
new Assertions.ExpectedMetric {metricName = @"DotNet/BasicWebService.TestWebService.HelloWorld", metricScope = "WebTransaction/WebService/BasicWebService.TestWebService.HelloWorld", callCount = 2}
new Assertions.ExpectedMetric {metricName = @"DotNet/System.Web.Services.Protocols.SyncSessionlessHandler/ProcessRequest", CallCountAllHarvests = 2 },
new Assertions.ExpectedMetric {metricName = @"DotNet/System.Web.Services.Protocols.SyncSessionlessHandler/ProcessRequest", metricScope = "WebTransaction/WebService/BasicWebService.TestWebService.HelloWorld", CallCountAllHarvests = 2},
new Assertions.ExpectedMetric {metricName = @"WebTransaction/WebService/BasicWebService.TestWebService.HelloWorld", CallCountAllHarvests = 2},
new Assertions.ExpectedMetric {metricName = @"DotNet/BasicWebService.TestWebService.HelloWorld", CallCountAllHarvests = 2},
new Assertions.ExpectedMetric {metricName = @"DotNet/BasicWebService.TestWebService.HelloWorld", metricScope = "WebTransaction/WebService/BasicWebService.TestWebService.HelloWorld", CallCountAllHarvests = 2}
};

var expectedTransactionTraceSegments = new List<string>
Expand Down
Loading

0 comments on commit ba9ee7b

Please sign in to comment.