public void Test() { var metrics = _fixture.AgentLog.GetMetrics().ToList(); Assert.NotNull(metrics); NrAssert.Multiple ( () => Assertions.MetricsExist(_generalMetrics, metrics), () => Assertions.MetricsExist(_ioBoundNoSpecialAsyncMetrics, metrics), () => Assertions.MetricsExist(_ioBoundConfigureAwaitFalseAsyncMetrics, metrics), () => Assertions.MetricsExist(_cpuBoundTasksAsyncMetrics, metrics), () => Assertions.MetricsExist(_manualAsyncTaskRunBlockedMetrics, metrics), () => Assertions.MetricsExist(_manualAsyncTaskFactoryStartNewBlockedMetrics, metrics), () => Assertions.MetricsExist(_manualAsyncNewThreadStartBlockedMetrics, metrics), () => Assertions.MetricsExist(_manualAsyncMultipleThreadSegmentParentingMetrics, metrics) ); var transactionSample = _fixture.AgentLog.GetTransactionSamples().FirstOrDefault(); Assert.NotNull(transactionSample); var actualTraceTree = transactionSample.TraceData.RootSegment; var expectedTraceTree = ExpectedTransactionTraceSegment.NewTree("ConsoleAsyncApplication.ManualAsyncUseCases", "MultipleThreadSegmentParenting", ExpectedTransactionTraceSegment.NewSubtree("MultipleThreadSegmentParenting", "ConsoleAsyncApplication.ManualAsyncUseCases", "MultipleThreadSegmentParenting", ExpectedTransactionTraceSegment.NewBackgroundThreadSubtree("DotNet/ConsoleAsyncApplication.ManualAsyncUseCases/Task1", "ConsoleAsyncApplication.ManualAsyncUseCases", "Task1", ExpectedTransactionTraceSegment.NewSubtree("DotNet/ConsoleAsyncApplication.ManualAsyncUseCases/Task1SubMethod1", "ConsoleAsyncApplication.ManualAsyncUseCases", "Task1SubMethod1"), ExpectedTransactionTraceSegment.NewSubtree("DotNet/ConsoleAsyncApplication.ManualAsyncUseCases/Task1SubMethod2", "ConsoleAsyncApplication.ManualAsyncUseCases", "Task1SubMethod2") ), ExpectedTransactionTraceSegment.NewBackgroundThreadSubtree("DotNet/ConsoleAsyncApplication.ManualAsyncUseCases/Task2", "ConsoleAsyncApplication.ManualAsyncUseCases", "Task2", ExpectedTransactionTraceSegment.NewSubtree("DotNet/ConsoleAsyncApplication.ManualAsyncUseCases/Task2SubMethod1", "ConsoleAsyncApplication.ManualAsyncUseCases", "Task2SubMethod1"), ExpectedTransactionTraceSegment.NewSubtree("DotNet/ConsoleAsyncApplication.ManualAsyncUseCases/Task2SubMethod2", "ConsoleAsyncApplication.ManualAsyncUseCases", "Task2SubMethod2") ), ExpectedTransactionTraceSegment.NewBackgroundThreadSubtree("DotNet/ConsoleAsyncApplication.ManualAsyncUseCases/Task3", "ConsoleAsyncApplication.ManualAsyncUseCases", "Task3", ExpectedTransactionTraceSegment.NewSubtree("DotNet/ConsoleAsyncApplication.ManualAsyncUseCases/Task3SubMethod1", "ConsoleAsyncApplication.ManualAsyncUseCases", "Task3SubMethod1"), ExpectedTransactionTraceSegment.NewSubtree("DotNet/ConsoleAsyncApplication.ManualAsyncUseCases/Task3SubMethod2", "ConsoleAsyncApplication.ManualAsyncUseCases", "Task3SubMethod2") ) ) ); Assertions.TransactionTraceSegmentTreeEquals(expectedTraceTree, actualTraceTree); }
public void BackgroundThreadMethodShouldNotOccurBeforeAnyPreceedingSyncMethods() { var expectedTraceTree = ExpectedTransactionTraceSegment.NewTree(ClassName, "RootMethod", ExpectedTransactionTraceSegment.NewSubtree("MetricNameRoot", ClassName, "RootMethod", ExpectedTransactionTraceSegment.NewBackgroundThreadSubtree("MetricName1", ClassName, "Method1", ExpectedTransactionTraceSegment.NewSubtree("MetricName11", ClassName, "Method11"), ExpectedTransactionTraceSegment.NewSubtree("MetricName12", ClassName, "Method12") ), ExpectedTransactionTraceSegment.NewSubtree("MetricName2", ClassName, "Method2", ExpectedTransactionTraceSegment.NewSubtree("MetricName21", ClassName, "Method21"), ExpectedTransactionTraceSegment.NewSubtree("MetricName22", ClassName, "Method22") ), // Method3 should not occur before synchronous Method2 in a transaction trace ExpectedTransactionTraceSegment.NewBackgroundThreadSubtree("MetricName3", ClassName, "Method3", ExpectedTransactionTraceSegment.NewSubtree("MetricName31", ClassName, "Method31"), ExpectedTransactionTraceSegment.NewSubtree("MetricName32", ClassName, "Method32") ) ) ); var actualTraceTree = TestTransactionTraceSegment.NewTree(ClassName, "RootMethod", TestTransactionTraceSegment.NewSubtree("MetricNameRoot", ClassName, "RootMethod", TestTransactionTraceSegment.NewSubtree("MetricName3", ClassName, "Method3", TestTransactionTraceSegment.NewSubtree("MetricName31", ClassName, "Method31"), TestTransactionTraceSegment.NewSubtree("MetricName32", ClassName, "Method32") ), TestTransactionTraceSegment.NewSubtree("MetricName2", ClassName, "Method2", TestTransactionTraceSegment.NewSubtree("MetricName21", ClassName, "Method21"), TestTransactionTraceSegment.NewSubtree("MetricName22", ClassName, "Method22") ), TestTransactionTraceSegment.NewSubtree("MetricName1", ClassName, "Method1", TestTransactionTraceSegment.NewSubtree("MetricName11", ClassName, "Method11"), TestTransactionTraceSegment.NewSubtree("MetricName12", ClassName, "Method12") ) ) ); var result = expectedTraceTree.CompareToActualTransactionTrace(actualTraceTree); Assert.False(result.IsEquivalent, result.Diff); }
public void BackgroundThreadMethodOrderingMayNotMatter() { var expectedTraceTree = ExpectedTransactionTraceSegment.NewTree(ClassName, "RootMethod", ExpectedTransactionTraceSegment.NewSubtree("MetricNameRoot", ClassName, "RootMethod", ExpectedTransactionTraceSegment.NewBackgroundThreadSubtree("MetricName1", ClassName, "Method1", ExpectedTransactionTraceSegment.NewSubtree("MetricName11", ClassName, "Method11"), ExpectedTransactionTraceSegment.NewSubtree("MetricName12", ClassName, "Method12") ), ExpectedTransactionTraceSegment.NewBackgroundThreadSubtree("MetricName2", ClassName, "Method2", ExpectedTransactionTraceSegment.NewSubtree("MetricName21", ClassName, "Method21"), ExpectedTransactionTraceSegment.NewSubtree("MetricName22", ClassName, "Method22") ), ExpectedTransactionTraceSegment.NewBackgroundThreadSubtree("MetricName3", ClassName, "Method3", ExpectedTransactionTraceSegment.NewSubtree("MetricName31", ClassName, "Method31"), ExpectedTransactionTraceSegment.NewSubtree("MetricName32", ClassName, "Method32") ) ) ); var actualTraceTree = TestTransactionTraceSegment.NewTree(ClassName, "RootMethod", TestTransactionTraceSegment.NewSubtree("MetricNameRoot", ClassName, "RootMethod", TestTransactionTraceSegment.NewSubtree("MetricName3", ClassName, "Method3", TestTransactionTraceSegment.NewSubtree("MetricName31", ClassName, "Method31"), TestTransactionTraceSegment.NewSubtree("MetricName32", ClassName, "Method32") ), TestTransactionTraceSegment.NewSubtree("MetricName2", ClassName, "Method2", TestTransactionTraceSegment.NewSubtree("MetricName21", ClassName, "Method21"), TestTransactionTraceSegment.NewSubtree("MetricName22", ClassName, "Method22") ), TestTransactionTraceSegment.NewSubtree("MetricName1", ClassName, "Method1", TestTransactionTraceSegment.NewSubtree("MetricName11", ClassName, "Method11"), TestTransactionTraceSegment.NewSubtree("MetricName12", ClassName, "Method12") ) ) ); var result = expectedTraceTree.CompareToActualTransactionTrace(actualTraceTree); Assert.True(result.IsEquivalent, result.Diff); }
public void ShouldEnsureCorrectIdenticalBackgroundThreadSubtreeCount() { var expectedTraceTree = ExpectedTransactionTraceSegment.NewTree(ClassName, "RootMethod", ExpectedTransactionTraceSegment.NewSubtree("MetricNameRoot", ClassName, "RootMethod", ExpectedTransactionTraceSegment.NewBackgroundThreadSubtree("MetricName1", ClassName, "Method1", ExpectedTransactionTraceSegment.NewSubtree("MetricName11", ClassName, "Method11"), ExpectedTransactionTraceSegment.NewSubtree("MetricName12", ClassName, "Method12") ), ExpectedTransactionTraceSegment.NewBackgroundThreadSubtree("MetricName1", ClassName, "Method1", ExpectedTransactionTraceSegment.NewSubtree("MetricName11", ClassName, "Method11"), ExpectedTransactionTraceSegment.NewSubtree("MetricName12", ClassName, "Method12") ), ExpectedTransactionTraceSegment.NewSubtree("MetricName2", ClassName, "Method2", ExpectedTransactionTraceSegment.NewSubtree("MetricName21", ClassName, "Method21"), ExpectedTransactionTraceSegment.NewSubtree("MetricName22", ClassName, "Method22") ) ) ); var actualTraceTree = TestTransactionTraceSegment.NewTree(ClassName, "RootMethod", TestTransactionTraceSegment.NewSubtree("MetricNameRoot", ClassName, "RootMethod", TestTransactionTraceSegment.NewSubtree("MetricName1", ClassName, "Method1", TestTransactionTraceSegment.NewSubtree("MetricName11", ClassName, "Method11"), TestTransactionTraceSegment.NewSubtree("MetricName12", ClassName, "Method12") ), TestTransactionTraceSegment.NewSubtree("MetricName2", ClassName, "Method2", TestTransactionTraceSegment.NewSubtree("MetricName21", ClassName, "Method21"), TestTransactionTraceSegment.NewSubtree("MetricName22", ClassName, "Method22") ) ) ); var result = expectedTraceTree.CompareToActualTransactionTrace(actualTraceTree); Assert.False(result.IsEquivalent, result.Diff); }