Skip to content

Commit

Permalink
test: Make metric validation more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
chynesNR committed Oct 21, 2024
1 parent a77919e commit e7de840
Show file tree
Hide file tree
Showing 39 changed files with 105 additions and 105 deletions.
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 @@ -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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public void Test()
{
var expectedMetrics = new List<Assertions.ExpectedMetric>()
{
new Assertions.ExpectedMetric {metricName = "Datastore/all", callCount = 3},
new Assertions.ExpectedMetric {metricName = "Datastore/Redis/all", callCount = 3},
new Assertions.ExpectedMetric {metricName = "Datastore/all", CallCountAllHarvests = 3},
new Assertions.ExpectedMetric {metricName = "Datastore/Redis/all", CallCountAllHarvests = 3},

new Assertions.ExpectedMetric {metricName = "Datastore/operation/Redis/" + ServiceStackRedisCommands.SaveAsync, callCount = 1},
new Assertions.ExpectedMetric {metricName = "Datastore/operation/Redis/" + ServiceStackRedisCommands.SaveAsync, metricScope = "WebTransaction/MVC/RedisController/Get", callCount = 1},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ public void Test()
{
var expectedMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric {metricName = $"WebTransaction", callCount = 2},
new Assertions.ExpectedMetric {metricName = $"OtherTransaction/all", callCount = 4},
new Assertions.ExpectedMetric {metricName = $"WebTransaction", CallCountAllHarvests = 2},
new Assertions.ExpectedMetric {metricName = $"OtherTransaction/all", CallCountAllHarvests = 4},

new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeWork", callCount = 3},
new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeWorkAsync", callCount = 2},
new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeMoreWorkAsync", callCount = 2},
new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeWork", CallCountAllHarvests = 3},
new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeWorkAsync", CallCountAllHarvests = 2},
new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/DoSomeMoreWorkAsync", CallCountAllHarvests = 2},

new Assertions.ExpectedMetric {metricName = $"WebTransaction/Custom/{LibraryClassName}/MakeWebTransaction", callCount = 1},
new Assertions.ExpectedMetric {metricName = $"DotNet/{LibraryClassName}/MakeWebTransaction", callCount = 1},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void Test()
new Assertions.ExpectedMetric { metricName = @"Supportability/DistributedTrace/AcceptPayload/Ignored/Null", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"Supportability/DistributedTrace/AcceptPayload/ParseException", callCount = 1 },
// The methods for GenerateAcceptSuccessMetric and GenerateCreateSuccessMetric result in AcceptPayload/Success metrics so we should look for two.
new Assertions.ExpectedMetric { metricName = @"Supportability/DistributedTrace/AcceptPayload/Success", callCount = 2 },
new Assertions.ExpectedMetric { metricName = @"Supportability/DistributedTrace/AcceptPayload/Success", CallCountAllHarvests = 2 },
new Assertions.ExpectedMetric { metricName = @"Supportability/DistributedTrace/AcceptPayload/Ignored/UntrustedAccount", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"Supportability/DistributedTrace/CreatePayload/Success", callCount = 1 },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override void Metrics()
{
new Assertions.ExpectedMetric { metricName = @"Supportability/ApiInvocation/InsertDistributedTraceHeaders", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"Supportability/ApiInvocation/AcceptDistributedTraceHeaders", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"Supportability/ApiInvocation/CurrentTransaction", callCount = 2 },
new Assertions.ExpectedMetric { metricName = @"Supportability/ApiInvocation/CurrentTransaction", CallCountAllHarvests = 2 },
new Assertions.ExpectedMetric { metricName = @"Supportability/TraceContext/Accept/Success", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"Supportability/TraceContext/Create/Success", callCount = 1 },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void Test()

var senderExpectedMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"Supportability/SpanEvent/TotalEventsSeen", callCount = 4 },
new Assertions.ExpectedMetric { metricName = @"Supportability/SpanEvent/TotalEventsSeen", CallCountAllHarvests = 4 },
new Assertions.ExpectedMetric { metricName = @"Supportability/TraceContext/Accept/Success", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"Supportability/TraceContext/Create/Success", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"Supportability/TraceContext/TraceState/NoNrEntry", callCount = 1 }
Expand All @@ -136,7 +136,7 @@ public void Test()

var receiverExpectedMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"Supportability/SpanEvent/TotalEventsSeen", callCount = 4 },
new Assertions.ExpectedMetric { metricName = @"Supportability/SpanEvent/TotalEventsSeen", CallCountAllHarvests = 4 },
new Assertions.ExpectedMetric { metricName = @"Supportability/TraceContext/Accept/Success", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"Supportability/TraceContext/Create/Success", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"DurationByCaller/App/{accountId}/{appId}/HTTP/all", callCount = 1 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void Test()

var unexpectedMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"OtherTransaction/all", callCount = 5 },
new Assertions.ExpectedMetric { metricName = @"OtherTransaction/all", CallCountAllHarvests = 5 },
};

var metrics = _fixture.AgentLog.GetMetrics().ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public void Test()
var expectedMetrics = new List<Assertions.ExpectedMetric>
{
// error metrics
new Assertions.ExpectedMetric {metricName = @"Errors/all", callCount = 2},
new Assertions.ExpectedMetric {metricName = @"Errors/allWeb", callCount = 2},
new Assertions.ExpectedMetric {metricName = @"Errors/WebTransaction/WebService/BasicWebService.TestWebService.ThrowException", callCount = 2},
new Assertions.ExpectedMetric {metricName = @"Errors/all", CallCountAllHarvests = 2},
new Assertions.ExpectedMetric {metricName = @"Errors/allWeb", CallCountAllHarvests = 2},
new Assertions.ExpectedMetric {metricName = @"Errors/WebTransaction/WebService/BasicWebService.TestWebService.ThrowException", CallCountAllHarvests = 2},

// other
new Assertions.ExpectedMetric {metricName = @"WebTransaction/WebService/BasicWebService.TestWebService.ThrowException", callCount = 2},
new Assertions.ExpectedMetric {metricName = @"DotNet/BasicWebService.TestWebService.ThrowException", callCount = 2},
new Assertions.ExpectedMetric {metricName = @"DotNet/BasicWebService.TestWebService.ThrowException", metricScope = "WebTransaction/WebService/BasicWebService.TestWebService.ThrowException", callCount = 2}
new Assertions.ExpectedMetric {metricName = @"WebTransaction/WebService/BasicWebService.TestWebService.ThrowException", CallCountAllHarvests = 2},
new Assertions.ExpectedMetric {metricName = @"DotNet/BasicWebService.TestWebService.ThrowException", CallCountAllHarvests = 2},
new Assertions.ExpectedMetric {metricName = @"DotNet/BasicWebService.TestWebService.ThrowException", metricScope = "WebTransaction/WebService/BasicWebService.TestWebService.ThrowException", CallCountAllHarvests = 2}
};

var unexpectedMetrics = new List<Assertions.ExpectedMetric>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public void Test()
{
var expectedMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"External/all", callCount = 3 },
new Assertions.ExpectedMetric { metricName = @"External/allOther", callCount = 3 },
new Assertions.ExpectedMetric { metricName = @"External/all", CallCountAllHarvests = 3 },
new Assertions.ExpectedMetric { metricName = @"External/allOther", CallCountAllHarvests = 3 },
new Assertions.ExpectedMetric { metricName = @"External/www.google.com/all", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"External/www.google.com/Stream/GET", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"External/www.google.com/Stream/GET", metricScope = @"OtherTransaction/Custom/MultiFunctionApplicationHelpers.NetStandardLibraries.Internal.HttpClientDriver/Get", callCount = 1 },
Expand Down
Loading

0 comments on commit e7de840

Please sign in to comment.