public void TestMultipleComponentsSucceeds() { var requestData = new RequestData(); Assert.AreEqual(0, TestSerializationHelper.GetComponentsListFromRequestData(requestData).Count); requestData.AddMetric("com.newrelic.test", "TestComponent1", "Test/Metric", "unit", 2); requestData.AddMetric("com.newrelic.test", "TestComponent2", "Test/Metric", "unit", 3); requestData.AddMetric("com.newrelic.test", "TestComponent3", "Test/Metric", "unit", 4); var componentsList = TestSerializationHelper.GetComponentsListFromRequestData(requestData); Assert.AreEqual(3, componentsList.Count); var component1 = TestSerializationHelper.GetComponentMapFromComponentsList(componentsList, "TestComponent1"); var component2 = TestSerializationHelper.GetComponentMapFromComponentsList(componentsList, "TestComponent2"); var component3 = TestSerializationHelper.GetComponentMapFromComponentsList(componentsList, "TestComponent3"); var metrics1 = TestSerializationHelper.GetMetricsMapFromComponentMap(component1); var metrics2 = TestSerializationHelper.GetMetricsMapFromComponentMap(component2); var metrics3 = TestSerializationHelper.GetMetricsMapFromComponentMap(component3); Assert.AreEqual(1, metrics1.Count); Assert.AreEqual(1, metrics2.Count); Assert.AreEqual(1, metrics3.Count); }
public void TestDifferentGuidDoesntAggregate() { var requestData = new RequestData(); requestData.AddMetric("com.newrelic.test", "TestComponent", "Test/Metric", "unit", 2); requestData.AddMetric("com.newrelic.anothertest", "TestComponent", "Test/Metric", "unit", 2); var componentsList = TestSerializationHelper.GetComponentsListFromRequestData(requestData); Assert.AreEqual(2, componentsList.Count); }
public void TestAggregateMetricsSucceeds() { var requestData = new RequestData(); Assert.AreEqual(0, TestSerializationHelper.GetComponentsListFromRequestData(requestData).Count); requestData.AddMetric("com.newrelic.test", "TestComponent", "Test/Metric", "unit", 2); requestData.AddMetric("com.newrelic.test", "TestComponent", "Test/Metric", "unit", 3); requestData.AddMetric("com.newrelic.test", "TestComponent", "Test/Metric", "unit", 4); var componentsList = TestSerializationHelper.GetComponentsListFromRequestData(requestData); Assert.AreEqual(1, componentsList.Count); var component = TestSerializationHelper.GetComponentMapFromComponentsList(componentsList, "TestComponent"); var metrics = TestSerializationHelper.GetMetricsMapFromComponentMap(component); Assert.AreEqual(1, metrics.Count); AssertMetricValues(metrics, "Component/Test/Metric[unit]", 9, 3, 2, 4, 29); }
public void TestResetComponentsSucceeds() { var requestData = new RequestData(); requestData.AddMetric("com.newrelic.test", "TestComponent1", "Test/Metric", "unit", 2); requestData.AddMetric("com.newrelic.test", "TestComponent2", "Test/Metric", "unit", 3); requestData.AddMetric("com.newrelic.test", "TestComponent3", "Test/Metric", "unit", 4); var beforeResetList = TestSerializationHelper.GetComponentsListFromRequestData(requestData); Assert.AreEqual(3, beforeResetList.Count); requestData.Reset(); var firstAfterResetList = TestSerializationHelper.GetComponentsListFromRequestData(requestData); Assert.AreEqual(0, firstAfterResetList.Count); requestData.AddMetric("com.newrelic.test", "TestComponent1", "Test/Metric", "unit", 2); requestData.AddMetric("com.newrelic.test", "TestComponent2", "Test/Metric", "unit", 3); requestData.AddMetric("com.newrelic.test", "TestComponent3", "Test/Metric", "unit", 4); var secondAfterResetList = TestSerializationHelper.GetComponentsListFromRequestData(requestData); Assert.AreEqual(3, secondAfterResetList.Count); }