示例#1
0
        private ImmutableTransaction BuildTestTransaction(string uri = null, string guid = null, int?statusCode = null, int?subStatusCode = null, IEnumerable <ErrorData> transactionExceptionDatas = null)
        {
            var transactionMetadata = new TransactionMetadata();

            if (uri != null)
            {
                transactionMetadata.SetUri(uri);
            }
            if (statusCode != null)
            {
                transactionMetadata.SetHttpResponseStatusCode(statusCode.Value, subStatusCode, _errorService);
            }
            if (transactionExceptionDatas != null)
            {
                transactionExceptionDatas.ForEach(data => transactionMetadata.TransactionErrorState.AddExceptionData(data));
            }

            var name     = TransactionName.ForWebTransaction("foo", "bar");
            var segments = Enumerable.Empty <Segment>();
            var metadata = transactionMetadata.ConvertToImmutableMetadata();

            guid = guid ?? Guid.NewGuid().ToString();

            var attribDefSvc = new AttributeDefinitionService((f) => new AttributeDefinitions(f));

            return(new ImmutableTransaction(name, segments, metadata, DateTime.UtcNow, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), guid, false, false, false, 0.5f, false, string.Empty, null, attribDefSvc.AttributeDefs));
        }
        public static ImmutableTransaction CreateTestTransactionWithSegments(IEnumerable <Segment> segments)
        {
            var uri = "sqlTrace/Uri";

            var transactionMetadata = new TransactionMetadata();

            transactionMetadata.SetUri(uri);

            var name     = TransactionName.ForWebTransaction("TxsWithSegments", "TxWithSegmentX");
            var metadata = transactionMetadata.ConvertToImmutableMetadata();
            var guid     = Guid.NewGuid().ToString();

            var transaction = new ImmutableTransaction(name, segments, metadata, DateTime.UtcNow, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), guid, false, false, false, 0.5f, false, string.Empty, null, _attribDefSvc.AttributeDefs);

            return(transaction);
        }
        private ImmutableTransaction BuildTestTransaction(DateTime?startTime = null, TimeSpan?duration = null, TimeSpan?responseTime = null, string uri = null, string guid = null)
        {
            var transactionMetadata = new TransactionMetadata();

            if (uri != null)
            {
                transactionMetadata.SetUri(uri);
            }

            var name     = TransactionName.ForWebTransaction("foo", "bar");
            var segments = Enumerable.Empty <Segment>();
            var metadata = transactionMetadata.ConvertToImmutableMetadata();

            startTime = startTime ?? DateTime.Now;
            duration  = duration ?? TimeSpan.FromSeconds(1);
            guid      = guid ?? Guid.NewGuid().ToString();

            return(new ImmutableTransaction(name, segments, metadata, startTime.Value, duration.Value, responseTime, guid, false, false, false, 1.2f, false, string.Empty, null, _attribDefs));
        }