private static Segment CreateSimpleSegment(int uniqueId, int?parentUniqueId, string name, TimeSpan startTime = new TimeSpan(), TimeSpan?duration = null, bool combinable = false) { duration = duration ?? TimeSpan.Zero; var methodCallData = new MethodCallData("foo", "bar", 1); return(SimpleSegmentDataTests.createSimpleSegmentBuilder(startTime, duration.Value, uniqueId, parentUniqueId, methodCallData, new Dictionary <string, object>(), name, combinable)); }
private static ImmutableSegmentTreeNode BuildNode(ImmutableTransaction transaction = null, DateTime?startTime = null, TimeSpan?duration = null, string name = "", MethodCallData methodCallData = null, IEnumerable <KeyValuePair <string, object> > parameters = null) { startTime = startTime ?? DateTime.Now; var relativeStart = startTime.Value - (transaction?.StartTime ?? startTime.Value); methodCallData = methodCallData ?? new MethodCallData("typeName", "methodName", 1); return(new SegmentTreeNodeBuilder(SimpleSegmentDataTests.createSimpleSegmentBuilder(relativeStart, duration ?? TimeSpan.Zero, 2, 1, methodCallData, parameters ?? new Dictionary <string, object>(), name, false)) .Build()); }
public static IInternalTransaction CreateDefaultTransaction(bool isWebTransaction = true, string uri = null, string guid = null, int?statusCode = null, int?subStatusCode = null, string referrerCrossProcessId = null, string transactionCategory = "defaultTxCategory", string transactionName = "defaultTxName", bool addSegment = true, IEnumerable <Segment> segments = null, bool sampled = false, IConfigurationService configurationService = null, Exception exception = null) { var name = isWebTransaction ? TransactionName.ForWebTransaction(transactionCategory, transactionName) : TransactionName.ForOtherTransaction(transactionCategory, transactionName); segments = segments ?? Enumerable.Empty <Segment>(); var placeholderMetadataBuilder = new TransactionMetadata(); var placeholderMetadata = placeholderMetadataBuilder.ConvertToImmutableMetadata(); var immutableTransaction = new ImmutableTransaction(name, segments, placeholderMetadata, DateTime.Now, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), guid, false, false, false, 0.5f, false, string.Empty, null, _attribDefSvc.AttributeDefs); var priority = 0.5f; var configuration = configurationService?.Configuration ?? GetDefaultConfiguration(); var errorService = configurationService != null ? new ErrorService(configurationService) : new ErrorService(Mock.Create <IConfigurationService>()); var internalTransaction = new Transaction(configuration, immutableTransaction.TransactionName, Mock.Create <ITimer>(), DateTime.UtcNow, Mock.Create <ICallStackManager>(), _databaseService, priority, Mock.Create <IDatabaseStatementParser>(), Mock.Create <IDistributedTracePayloadHandler>(), errorService, _attribDefSvc.AttributeDefs); if (exception != null) { internalTransaction.NoticeError(exception); } if (segments.Any()) { foreach (var segment in segments) { internalTransaction.Add(segment); } } else if (addSegment) { internalTransaction.Add(SimpleSegmentDataTests.createSimpleSegmentBuilder(TimeSpan.Zero, TimeSpan.Zero, 0, null, new MethodCallData("typeName", "methodName", 1), Enumerable.Empty <KeyValuePair <string, object> >(), "MyMockedRootNode", false)); } var adaptiveSampler = Mock.Create <IAdaptiveSampler>(); Mock.Arrange(() => adaptiveSampler.ComputeSampled(ref priority)).Returns(sampled); internalTransaction.SetSampled(adaptiveSampler); var transactionMetadata = internalTransaction.TransactionMetadata; PopulateTransactionMetadataBuilder(transactionMetadata, errorService, uri, statusCode, subStatusCode, referrerCrossProcessId); return(internalTransaction); }
private static SegmentTreeNodeBuilder GetNodeBuilder(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); return(new SegmentTreeNodeBuilder(SimpleSegmentDataTests.createSimpleSegmentBuilder(startTime, duration ?? TimeSpan.Zero, 2, 1, methodCallData, parameters ?? new Dictionary <string, object>(), name, false))); }