private static Segment GetSegment(string type, string method)
        {
            var builder = new Segment(TransactionSegmentStateHelpers.GetItransactionSegmentState(), new MethodCallData("foo", "bar", 1));

            builder.SetSegmentData(new MethodSegmentData(type, method));
            builder.End();
            return(builder);
        }
Esempio n. 2
0
        private static Segment GetFinishedSegment(DateTime transactionStartTime, DateTime startTime, TimeSpan?duration)
        {
            var segment = new Segment(TransactionSegmentStateHelpers.GetItransactionSegmentState(), new MethodCallData("type", "method", 1));

            segment.SetSegmentData(new SimpleSegmentData(""));

            return(new Segment(startTime - transactionStartTime, duration, segment, null));
        }
Esempio n. 3
0
        private Segment GetSegment(DatastoreVendor vendor, string operation, string model)
        {
            var data    = new DatastoreSegmentData(_databaseService, new ParsedSqlStatement(vendor, model, operation));
            var segment = new Segment(TransactionSegmentStateHelpers.GetItransactionSegmentState(), new MethodCallData("foo", "bar", 1));

            segment.SetSegmentData(data);

            return(segment);
        }
        private static Segment GetSegment(string uri, string method, CrossApplicationResponseData catResponseData = null)
        {
            var data    = new ExternalSegmentData(new Uri(uri), method, catResponseData);
            var builder = new Segment(TransactionSegmentStateHelpers.GetItransactionSegmentState(), new MethodCallData("foo", "bar", 1));

            builder.SetSegmentData(data);
            builder.End();
            return(builder);
        }
        private static Segment GetSegment(string vendor, MetricNames.MessageBrokerDestinationType destinationType, string destination, MetricNames.MessageBrokerAction action)
        {
            var builder = new Segment(TransactionSegmentStateHelpers.GetItransactionSegmentState(), new MethodCallData("foo", "bar", 1));

            builder.SetSegmentData(new MessageBrokerSegmentData(vendor, destination, destinationType, action));
            builder.End();

            return(builder);
        }
        private static Segment GetSegment(string name, double duration)
        {
            var methodCallData = new MethodCallData("foo", "bar", 1);
            var segment        = new Segment(TransactionSegmentStateHelpers.GetItransactionSegmentState(), methodCallData);

            segment.SetSegmentData(new CustomSegmentData(name));

            return(new Segment(new TimeSpan(), TimeSpan.FromSeconds(duration), segment, null));
        }
Esempio n. 7
0
        private Segment GetSegment(DatastoreVendor vendor, string operation, string model, double duration, CrossApplicationResponseData catResponseData = null, string host = null, string portPathOrId = null)
        {
            var methodCallData = new MethodCallData("foo", "bar", 1);
            var data           = new DatastoreSegmentData(_databaseService, new ParsedSqlStatement(vendor, model, operation), null, new ConnectionInfo(host, portPathOrId, null));
            var segment        = new Segment(TransactionSegmentStateHelpers.GetItransactionSegmentState(), methodCallData);

            segment.SetSegmentData(data);

            return(segment.CreateSimilar(new TimeSpan(), TimeSpan.FromSeconds(duration), null));
        }
        private static Segment GetSegment(string uri, string method, double duration, CrossApplicationResponseData catResponseData = null)
        {
            var methodCallData = new MethodCallData("foo", "bar", 1);

            var data    = new ExternalSegmentData(new Uri(uri), method, catResponseData);
            var segment = new Segment(TransactionSegmentStateHelpers.GetItransactionSegmentState(), methodCallData);

            segment.SetSegmentData(data);

            return(new Segment(new TimeSpan(), TimeSpan.FromSeconds(duration), segment, null));
        }
        private static ImmutableSegmentTreeNode BuildNode(TimeSpan relativeStart = new TimeSpan(), TimeSpan?duration = null)
        {
            var methodCallData = new MethodCallData("typeName", "methodName", 1);
            var segment        = new Segment(TransactionSegmentStateHelpers.GetItransactionSegmentState(), methodCallData);

            segment.SetSegmentData(new SimpleSegmentData(""));

            return(new SegmentTreeNodeBuilder(
                       new Segment(relativeStart, duration ?? TimeSpan.Zero, segment, null))
                   .Build());
        }
        private Segment BuildSegment(DatastoreVendor vendor, string model, string commandText, TimeSpan startTime = new TimeSpan(), TimeSpan?duration = null, string name = "", MethodCallData methodCallData = null, IEnumerable <KeyValuePair <string, object> > parameters = null, string host = null, string portPathOrId = null, string databaseName = null)
        {
            var data = new DatastoreSegmentData(_databaseService, new ParsedSqlStatement(vendor, model, null), commandText,
                                                new ConnectionInfo(host, portPathOrId, databaseName));

            methodCallData = methodCallData ?? new MethodCallData("typeName", "methodName", 1);

            var segment = new Segment(TransactionSegmentStateHelpers.GetItransactionSegmentState(), methodCallData);

            segment.SetSegmentData(data);

            return(new Segment(startTime, duration, segment, parameters));
        }
        private ImmutableSegmentTreeNode BuildDataStoreSegmentNode(TimeSpan startTime = new TimeSpan(), TimeSpan?duration = null, string name = "", MethodCallData methodCallData = null, IEnumerable <KeyValuePair <string, object> > parameters = null)
        {
            methodCallData = methodCallData ?? new MethodCallData("typeName", "methodName", 1);

            var data = new DatastoreSegmentData(_databaseService, new ParsedSqlStatement(DatastoreVendor.MSSQL, "test_table", "SELECT"), "SELECT * FROM test_table");

            var segment = new Segment(TransactionSegmentStateHelpers.GetItransactionSegmentState(), methodCallData);

            segment.SetSegmentData(data);

            return(new SegmentTreeNodeBuilder(
                       new Segment(startTime, duration ?? TimeSpan.Zero, segment, parameters))
                   .Build());
        }
Esempio n. 12
0
        public void multiple_sqlId_does_not_has_9_digits_number()
        {
            var transactionMetadata = new TransactionMetadata();
            var name     = TransactionName.ForWebTransaction("foo", "bar");
            var metadata = transactionMetadata.ConvertToImmutableMetadata();
            var duration = TimeSpan.FromSeconds(1);
            var guid     = Guid.NewGuid().ToString();
            var transactionMetricName = new TransactionMetricName("WebTransaction", "Name");
            var databaseService       = new DatabaseService(Mock.Create <ICacheStatsReporter>());
            var configurationService  = Mock.Create <IConfigurationService>();
            var attribDefSvc          = new AttributeDefinitionService((f) => new AttributeDefinitions(f));

            string[] queries = { Sql,                                                                                               "Select * from someTable", "Insert x into anotherTable",             "another random string",
                                 "1234567890!@#$%^&*()",                                                                            "fjdksalfjdkla;fjdla;",    "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
                                 "NNNNNNNNNNNUUUUUUUUUUUUUUUUTTTTTTTTTTTTTTTHHHHHHHHHHHHHIIIIIIIIIIIIIIIIIIIINNNNNNNNNNNNNNNNNNNN",
                                 double.MaxValue.ToString() };
            var      sqlTraceMaker = new SqlTraceMaker(configurationService, attribDefSvc, databaseService);
            var      traceDatas    = new List <SqlTraceWireModel>();

            foreach (string query in queries)
            {
                var data    = new DatastoreSegmentData(databaseService, new ParsedSqlStatement(DatastoreVendor.MSSQL, null, null), query);
                var segment = new Segment(TransactionSegmentStateHelpers.GetItransactionSegmentState(), new MethodCallData("typeName", "methodName", 1));
                segment.SetSegmentData(data);

                var segments = new List <Segment>()
                {
                    new Segment(new TimeSpan(), TotalCallTime, segment, null)
                };
                var immutableTransaction = new ImmutableTransaction(name, segments, metadata, DateTime.Now, duration, duration, guid, false, false, false, 1.2f, false, string.Empty, null, _attribDefs);

                var sqlTraceData = sqlTraceMaker.TryGetSqlTrace(immutableTransaction, transactionMetricName, immutableTransaction.Segments.FirstOrDefault());
                traceDatas.Add(sqlTraceData);
            }

            foreach (SqlTraceWireModel traceData in traceDatas)
            {
                var numberOfDigits = Math.Floor(Math.Log10(traceData.SqlId) + 1);
                Assert.IsTrue(numberOfDigits != 9);
            }
        }