public void SqlParsingCacheMetricsAreResetBetweenHarvests() { _agent.CreateTransaction( isWeb: true, category: EnumNameCache <WebTransactionType> .GetName(WebTransactionType.Action), transactionDisplayName: "name", doNotTrackAsUnitOfWork: true); _agent.StartDatastoreRequestSegmentOrThrow(DatastoreVendor.MSSQL, CommandType.Text, "SELECT * FROM Table1").End(); _agent.StartDatastoreRequestSegmentOrThrow(DatastoreVendor.MSSQL, CommandType.Text, "SELECT * FROM Table1").End(); _agent.StartDatastoreRequestSegmentOrThrow(DatastoreVendor.MSSQL, CommandType.Text, "SELECT * FROM Table1").End(); _agent.StartDatastoreRequestSegmentOrThrow(DatastoreVendor.MSSQL, CommandType.Text, "SELECT * FROM Table2").End(); _agent.StartDatastoreRequestSegmentOrThrow(DatastoreVendor.MSSQL, CommandType.Text, "SELECT * FROM Table2").End(); _agent.StartDatastoreRequestSegmentOrThrow(DatastoreVendor.IBMDB2, CommandType.Text, "SELECT * FROM Table1").End(); _agent.StartDatastoreRequestSegmentOrThrow(DatastoreVendor.IBMDB2, CommandType.Text, "SELECT * FROM Table1").End(); const int defaultCapacity = 1000; // ASSERT var expectedMetrics = new List <ExpectedMetric> { new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/MSSQL/Capacity", CallCount = 1, Total = defaultCapacity }, new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/MSSQL/Hits", CallCount = 3 }, new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/MSSQL/Misses", CallCount = 2 }, new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/MSSQL/Ejections", CallCount = 0 }, new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/MSSQL/Size", CallCount = 1, Total = 2 }, new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/IBMDB2/Capacity", CallCount = 1, Total = defaultCapacity }, new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/IBMDB2/Hits", CallCount = 1 }, new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/IBMDB2/Misses", CallCount = 1 }, new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/IBMDB2/Ejections", CallCount = 0 }, new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/IBMDB2/Size", CallCount = 1, Total = 1 } }; _compositeTestAgent.Harvest(); MetricAssertions.MetricsExist(expectedMetrics, _compositeTestAgent.Metrics); _agent.StartDatastoreRequestSegmentOrThrow(DatastoreVendor.MSSQL, CommandType.Text, "SELECT * FROM Table1").End(); _agent.StartDatastoreRequestSegmentOrThrow(DatastoreVendor.MSSQL, CommandType.Text, "SELECT * FROM Table1").End(); expectedMetrics = new List <ExpectedMetric> { new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/MSSQL/Capacity", CallCount = 1, Total = defaultCapacity }, new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/MSSQL/Hits", CallCount = 2 }, new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/MSSQL/Misses", CallCount = 0 }, new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/MSSQL/Ejections", CallCount = 0 }, new ExpectedCountMetric { Name = SqlParsingCacheMetricPrefix + "/MSSQL/Size", CallCount = 1, Total = 2 } }; _compositeTestAgent.ResetHarvestData(); _compositeTestAgent.Harvest(); MetricAssertions.MetricsExist(expectedMetrics, _compositeTestAgent.Metrics); }