public void TransformSegment_TwoTransformCallsSame()
        {
            const string type    = "type";
            const string method  = "method";
            var          segment = GetSegment(type, method);;

            var txName  = new TransactionMetricName("WebTransaction", "Test", false);
            var txStats = new TransactionMetricStatsCollection(txName);

            segment.AddMetricStats(txStats, _configurationService);
            segment.AddMetricStats(txStats, _configurationService);

            var scoped   = txStats.GetScopedForTesting();
            var unscoped = txStats.GetUnscopedForTesting();

            Assert.AreEqual(1, scoped.Count);
            Assert.AreEqual(1, unscoped.Count);

            const string metricName = "DotNet/type/method";

            Assert.IsTrue(scoped.ContainsKey(metricName));
            Assert.IsTrue(unscoped.ContainsKey(metricName));

            var nameScoped   = scoped[metricName];
            var nameUnscoped = unscoped[metricName];

            Assert.AreEqual(2, nameScoped.Value0);
            Assert.AreEqual(2, nameUnscoped.Value0);
        }
        public void TransformSegment_TwoTransformCallsSame()
        {
            const string vendor      = "vendor1";
            const string destination = "queueA";
            const MetricNames.MessageBrokerDestinationType destinationType = MetricNames.MessageBrokerDestinationType.Queue;
            const MetricNames.MessageBrokerAction          action          = MetricNames.MessageBrokerAction.Consume;
            var segment = GetSegment(vendor, destinationType, destination, action);
            TransactionMetricName            txName  = new TransactionMetricName("WebTransaction", "Test", false);
            TransactionMetricStatsCollection txStats = new TransactionMetricStatsCollection(txName);

            segment.AddMetricStats(txStats, _configurationService);

            segment.AddMetricStats(txStats, _configurationService);

            var scoped   = txStats.GetScopedForTesting();
            var unscoped = txStats.GetUnscopedForTesting();

            Assert.AreEqual(1, scoped.Count);
            Assert.AreEqual(1, unscoped.Count);
            const string metricName = "MessageBroker/vendor1/Queue/Consume/Named/queueA";


            Assert.IsTrue(scoped.ContainsKey(metricName));
            Assert.IsTrue(unscoped.ContainsKey(metricName));

            var nameScoped   = scoped[metricName];
            var nameUnscoped = unscoped[metricName];

            Assert.AreEqual(2, nameScoped.Value0);
            Assert.AreEqual(2, nameUnscoped.Value0);
        }
Example #3
0
        public void TransformSegment_CreatesNullModelSegmentMetrics()
        {
            var wrapperVendor = Extensions.Providers.Wrapper.DatastoreVendor.MSSQL;
            var model         = null as string;
            var operation     = "INSERT";

            var segment = GetSegment(wrapperVendor, operation, model, 5);


            var txName  = new TransactionMetricName("WebTransaction", "Test", false);
            var txStats = new TransactionMetricStatsCollection(txName);

            segment.AddMetricStats(txStats, _configurationService);


            var scoped   = txStats.GetScopedForTesting();
            var unscoped = txStats.GetUnscopedForTesting();

            Assert.AreEqual(1, scoped.Count);
            Assert.AreEqual(5, unscoped.Count);

            //no statement metric for null model
            const string statementMetric = "Datastore/statement/MSSQL/MY_TABLE/INSERT";
            const string operationMetric = "Datastore/operation/MSSQL/INSERT";

            Assert.IsTrue(unscoped.ContainsKey("Datastore/all"));
            Assert.IsTrue(unscoped.ContainsKey("Datastore/allWeb"));
            Assert.IsTrue(unscoped.ContainsKey("Datastore/MSSQL/all"));
            Assert.IsTrue(unscoped.ContainsKey("Datastore/MSSQL/allWeb"));
            Assert.IsFalse(unscoped.ContainsKey(statementMetric));
            Assert.IsTrue(unscoped.ContainsKey(operationMetric));

            Assert.IsTrue(scoped.ContainsKey(operationMetric));

            var data = scoped[operationMetric];

            Assert.AreEqual(1, data.Value0);
            Assert.AreEqual(5, data.Value1);
            Assert.AreEqual(5, data.Value2);
            Assert.AreEqual(5, data.Value3);
            Assert.AreEqual(5, data.Value4);

            var unscopedMetricsWithExclusiveTime = new string[] { operationMetric, "Datastore/all", "Datastore/allWeb", "Datastore/MSSQL/all", "Datastore/MSSQL/allWeb" };

            foreach (var current in unscopedMetricsWithExclusiveTime)
            {
                data = unscoped[current];
                Assert.AreEqual(1, data.Value0);
                Assert.AreEqual(5, data.Value1);
                Assert.AreEqual(5, data.Value2);
                Assert.AreEqual(5, data.Value3);
                Assert.AreEqual(5, data.Value4);
            }
        }
        public void TransformSegment_CreatesWebWithCat()
        {
            const string host   = "www.bar.com";
            var          uri    = $"http://{host}/foo";
            const string method = "GET";
            var          externalCrossProcessId  = "cpId";
            var          externalTransactionName = "otherTxName";
            var          catResponseData         = new CrossApplicationResponseData(externalCrossProcessId, externalTransactionName, 1.1f, 2.2f, 3, "guid", false);

            var segment = GetSegment(uri, method, catResponseData);


            var txName  = new TransactionMetricName("WebTransaction", "Test", false);
            var txStats = new TransactionMetricStatsCollection(txName);

            segment.AddMetricStats(txStats, _configurationService);

            var scoped   = txStats.GetScopedForTesting();
            var unscoped = txStats.GetUnscopedForTesting();

            Assert.AreEqual(1, scoped.Count);
            Assert.AreEqual(6, unscoped.Count);

            const string segmentMetric = "External/www.bar.com/Stream/GET";
            const string txMetric      = "ExternalTransaction/www.bar.com/cpId/otherTxName";

            Assert.IsTrue(unscoped.ContainsKey("External/all"));
            Assert.IsTrue(unscoped.ContainsKey("External/allWeb"));
            Assert.IsTrue(unscoped.ContainsKey("External/www.bar.com/all"));
            Assert.IsTrue(unscoped.ContainsKey(segmentMetric));
            Assert.IsTrue(unscoped.ContainsKey(txMetric));
            Assert.IsTrue(unscoped.ContainsKey("ExternalApp/www.bar.com/cpId/all"));

            Assert.IsFalse(scoped.ContainsKey(segmentMetric));
            Assert.IsTrue(scoped.ContainsKey(txMetric));

            var nameScoped   = scoped[txMetric];
            var nameUnscoped = unscoped[txMetric];

            Assert.AreEqual(1, nameScoped.Value0);
            Assert.AreEqual(1, nameUnscoped.Value0);
        }
        public void TransformSegment_TwoTransformCallsDifferent()
        {
            const string name    = "name";
            var          segment = GetSegment(name);

            const string name1    = "otherName";
            var          segment1 = GetSegment(name1);

            var txName  = new TransactionMetricName("WebTransaction", "Test", false);
            var txStats = new TransactionMetricStatsCollection(txName);

            segment.AddMetricStats(txStats, _configurationService);
            segment1.AddMetricStats(txStats, _configurationService);

            var scoped   = txStats.GetScopedForTesting();
            var unscoped = txStats.GetUnscopedForTesting();

            Assert.AreEqual(2, scoped.Count);
            Assert.AreEqual(2, unscoped.Count);

            const string metricName = "DotNet/name";

            Assert.IsTrue(scoped.ContainsKey(metricName));
            Assert.IsTrue(unscoped.ContainsKey(metricName));

            var nameScoped   = scoped[metricName];
            var nameUnscoped = unscoped[metricName];

            Assert.AreEqual(1, nameScoped.Value0);
            Assert.AreEqual(1, nameUnscoped.Value0);

            const string metricName1 = "DotNet/otherName";

            Assert.IsTrue(scoped.ContainsKey(metricName1));
            Assert.IsTrue(unscoped.ContainsKey(metricName1));

            nameScoped   = scoped[metricName1];
            nameUnscoped = unscoped[metricName1];

            Assert.AreEqual(1, nameScoped.Value0);
            Assert.AreEqual(1, nameUnscoped.Value0);
        }
        public void TransformSegment_CreatesCustomSegmentMetrics()
        {
            const string type    = "type";
            const string method  = "method";
            var          segment = GetSegment(type, method, 5);

            segment.ChildFinished(GetSegment("kid", "method", 2));

            var txName  = new TransactionMetricName("WebTransaction", "Test", false);
            var txStats = new TransactionMetricStatsCollection(txName);

            segment.AddMetricStats(txStats, _configurationService);


            var scoped   = txStats.GetScopedForTesting();
            var unscoped = txStats.GetUnscopedForTesting();

            Assert.AreEqual(1, scoped.Count);
            Assert.AreEqual(1, unscoped.Count);

            const string metricName = "DotNet/type/method";

            Assert.IsTrue(scoped.ContainsKey(metricName));
            Assert.IsTrue(unscoped.ContainsKey(metricName));

            var data = scoped[metricName];

            Assert.AreEqual(1, data.Value0);
            Assert.AreEqual(5, data.Value1);
            Assert.AreEqual(3, data.Value2);
            Assert.AreEqual(5, data.Value3);
            Assert.AreEqual(5, data.Value4);

            data = unscoped[metricName];
            Assert.AreEqual(1, data.Value0);
            Assert.AreEqual(5, data.Value1);
            Assert.AreEqual(3, data.Value2);
            Assert.AreEqual(5, data.Value3);
            Assert.AreEqual(5, data.Value4);
        }
        public void TransformSegment_TwoTransformCallsSame()
        {
            const string name    = "name";
            var          segment = GetSegment(name, 5);

            segment.ChildFinished(GetSegment("kid", 2));

            var txName  = new TransactionMetricName("WebTransaction", "Test", false);
            var txStats = new TransactionMetricStatsCollection(txName);

            segment.AddMetricStats(txStats, _configurationService);
            segment.ChildFinished(GetSegment("kid", 2));
            segment.AddMetricStats(txStats, _configurationService);

            var scoped   = txStats.GetScopedForTesting();
            var unscoped = txStats.GetUnscopedForTesting();

            const string metricName = "Custom/name";

            Assert.IsTrue(scoped.ContainsKey(metricName));
            Assert.IsTrue(unscoped.ContainsKey(metricName));

            var data = scoped[metricName];

            Assert.AreEqual(2, data.Value0);
            Assert.AreEqual(10, data.Value1);
            Assert.AreEqual(4, data.Value2);
            Assert.AreEqual(5, data.Value3);
            Assert.AreEqual(5, data.Value4);

            data = unscoped[metricName];
            Assert.AreEqual(2, data.Value0);
            Assert.AreEqual(10, data.Value1);
            Assert.AreEqual(4, data.Value2);
            Assert.AreEqual(5, data.Value3);
            Assert.AreEqual(5, data.Value4);
        }
Example #8
0
        public void TransformSegment_CreatesInstanceMetrics()
        {
            var wrapperVendor = Extensions.Providers.Wrapper.DatastoreVendor.MSSQL;
            var model         = "MY_TABLE";
            var operation     = "INSERT";
            var host          = "HOST";
            var portPathOrId  = "8080";

            var segment = GetSegment(wrapperVendor, operation, model, 5, host: host, portPathOrId: portPathOrId);

            var txName  = new TransactionMetricName("OtherTransaction", "Test", false);
            var txStats = new TransactionMetricStatsCollection(txName);

            Mock.Arrange(() => _configurationService.Configuration.InstanceReportingEnabled).Returns(true);

            segment.AddMetricStats(txStats, _configurationService);

            var scoped   = txStats.GetScopedForTesting();
            var unscoped = txStats.GetUnscopedForTesting();

            Assert.AreEqual(1, scoped.Count);
            Assert.AreEqual(7, unscoped.Count);

            const string statementMetric = "Datastore/statement/MSSQL/MY_TABLE/INSERT";
            const string operationMetric = "Datastore/operation/MSSQL/INSERT";
            const string instanceMetric  = "Datastore/instance/MSSQL/HOST/8080";

            Assert.IsTrue(unscoped.ContainsKey("Datastore/all"));
            Assert.IsTrue(unscoped.ContainsKey("Datastore/allOther"));
            Assert.IsTrue(unscoped.ContainsKey("Datastore/MSSQL/all"));
            Assert.IsTrue(unscoped.ContainsKey("Datastore/MSSQL/allOther"));
            Assert.IsTrue(unscoped.ContainsKey(statementMetric));
            Assert.IsTrue(unscoped.ContainsKey(operationMetric));
            Assert.IsTrue(unscoped.ContainsKey(instanceMetric));

            Assert.IsTrue(scoped.ContainsKey(statementMetric));

            var data = scoped[statementMetric];

            Assert.AreEqual(1, data.Value0);
            Assert.AreEqual(5, data.Value1);
            Assert.AreEqual(5, data.Value2);
            Assert.AreEqual(5, data.Value3);
            Assert.AreEqual(5, data.Value4);

            var unscopedMetricsWithExclusiveTime = new string[] { statementMetric, operationMetric, "Datastore/all", "Datastore/allOther", "Datastore/MSSQL/all", "Datastore/MSSQL/allOther" };

            foreach (var current in unscopedMetricsWithExclusiveTime)
            {
                data = unscoped[current];
                Assert.AreEqual(1, data.Value0);
                Assert.AreEqual(5, data.Value1);
                Assert.AreEqual(5, data.Value2);
                Assert.AreEqual(5, data.Value3);
                Assert.AreEqual(5, data.Value4);
            }

            data = unscoped[instanceMetric];
            Assert.AreEqual(1, data.Value0);
            Assert.AreEqual(5, data.Value1);
            Assert.AreEqual(5, data.Value2);
            Assert.AreEqual(5, data.Value3);
            Assert.AreEqual(5, data.Value4);
        }
        public void TransformSegment_CreatesWebSegmentMetrics()
        {
            const string host   = "www.foo.com";
            var          uri    = $"http://{host}/bar";
            const string method = "GET";

            var segment = GetSegment(uri, method, 5);


            var txName  = new TransactionMetricName("WebTransaction", "Test", false);
            var txStats = new TransactionMetricStatsCollection(txName);

            segment.AddMetricStats(txStats, _configurationService);

            var scoped   = txStats.GetScopedForTesting();
            var unscoped = txStats.GetUnscopedForTesting();

            Assert.AreEqual(1, scoped.Count);
            Assert.AreEqual(4, unscoped.Count);

            const string segmentMetric = "External/www.foo.com/Stream/GET";

            Assert.IsTrue(unscoped.ContainsKey("External/all"));
            Assert.IsTrue(unscoped.ContainsKey("External/allWeb"));
            Assert.IsTrue(unscoped.ContainsKey("External/www.foo.com/all"));
            Assert.IsTrue(unscoped.ContainsKey(segmentMetric));

            Assert.IsTrue(scoped.ContainsKey(segmentMetric));

            var data = scoped[segmentMetric];

            Assert.AreEqual(1, data.Value0);
            Assert.AreEqual(5, data.Value1);
            Assert.AreEqual(5, data.Value2);
            Assert.AreEqual(5, data.Value3);
            Assert.AreEqual(5, data.Value4);

            var unscopedMetricsUsingDurationOnly = new string[] { "External/all", "External/allWeb", "External/www.foo.com/all" };

            foreach (var current in unscopedMetricsUsingDurationOnly)
            {
                data = unscoped[current];
                Assert.AreEqual(1, data.Value0);
                Assert.AreEqual(5, data.Value1);
                Assert.AreEqual(5, data.Value2);
                Assert.AreEqual(5, data.Value3);
                Assert.AreEqual(5, data.Value4);
            }

            var unscopedMetricsUsingExclusive = new string[] { segmentMetric };

            foreach (var current in unscopedMetricsUsingExclusive)
            {
                data = unscoped[current];
                Assert.AreEqual(1, data.Value0);
                Assert.AreEqual(5, data.Value1);
                Assert.AreEqual(5, data.Value2);
                Assert.AreEqual(5, data.Value3);
                Assert.AreEqual(5, data.Value4);
            }
        }
        public void TransformSegment_CreatesOtherWithCat()
        {
            const string host   = "www.bar.com";
            var          uri    = $"http://{host}/foo";
            const string method = "GET";
            var          externalCrossProcessId  = "cpId";
            var          externalTransactionName = "name";
            var          catResponseData         = new CrossApplicationResponseData(externalCrossProcessId, externalTransactionName, 1.1f, 2.2f, 3, "guid", false);

            var segment = GetSegment(uri, method, 5, catResponseData);


            var txName  = new TransactionMetricName("OtherTransaction", "Test", false);
            var txStats = new TransactionMetricStatsCollection(txName);

            segment.AddMetricStats(txStats, _configurationService);

            var scoped   = txStats.GetScopedForTesting();
            var unscoped = txStats.GetUnscopedForTesting();

            Assert.AreEqual(1, scoped.Count);
            Assert.AreEqual(6, unscoped.Count);

            const string segmentMetric = "External/www.bar.com/Stream/GET";
            const string txMetric      = "ExternalTransaction/www.bar.com/cpId/name";

            Assert.IsTrue(unscoped.ContainsKey("External/all"));
            Assert.IsTrue(unscoped.ContainsKey("External/allOther"));
            Assert.IsTrue(unscoped.ContainsKey("External/www.bar.com/all"));
            Assert.IsTrue(unscoped.ContainsKey(segmentMetric));
            Assert.IsTrue(unscoped.ContainsKey(txMetric));
            Assert.IsTrue(unscoped.ContainsKey("ExternalApp/www.bar.com/cpId/all"));

            Assert.IsFalse(scoped.ContainsKey(segmentMetric));
            Assert.IsTrue(scoped.ContainsKey(txMetric));

            var data = scoped[txMetric];

            Assert.AreEqual(1, data.Value0);
            Assert.AreEqual(5, data.Value1);
            Assert.AreEqual(5, data.Value2);
            Assert.AreEqual(5, data.Value3);
            Assert.AreEqual(5, data.Value4);

            var unscopedMetricsUsingDurationOnly = new string[] { "External/all", "External/allOther", "External/www.bar.com/all" };

            foreach (var current in unscopedMetricsUsingDurationOnly)
            {
                data = unscoped[current];
                Assert.AreEqual(1, data.Value0);
                Assert.AreEqual(5, data.Value1);
                Assert.AreEqual(5, data.Value2);
                Assert.AreEqual(5, data.Value3);
                Assert.AreEqual(5, data.Value4);
            }

            var unscopedMetricsUsingExclusive = new string[] { segmentMetric, txMetric };

            foreach (var current in unscopedMetricsUsingExclusive)
            {
                data = unscoped[current];
                Assert.AreEqual(1, data.Value0);
                Assert.AreEqual(5, data.Value1);
                Assert.AreEqual(5, data.Value2);
                Assert.AreEqual(5, data.Value3);
                Assert.AreEqual(5, data.Value4);
            }

            data = unscoped["ExternalApp/www.bar.com/cpId/all"];
            Assert.AreEqual(1, data.Value0);
            Assert.AreEqual(5, data.Value1);
            Assert.AreEqual(5, data.Value2);
            Assert.AreEqual(5, data.Value3);
            Assert.AreEqual(5, data.Value4);
        }