public void GetSpanEvent_ReturnsSpanEventPerSegment_W3CAttributes() { // ARRANGE var segments = new List <Segment>() { _baseGenericSegment.CreateSimilar(TimeSpan.FromMilliseconds(1), TimeSpan.FromMilliseconds(5), new List <KeyValuePair <string, object> >()) }; var immutableTransaction = new ImmutableTransactionBuilder() .WithW3CTracing(DistributedTraceGuid, W3cParentId, VendorStateEntries) .Build(); var transactionMetricName = _transactionMetricNameMaker.GetTransactionMetricName(immutableTransaction.TransactionName); var metricStatsCollection = new TransactionMetricStatsCollection(transactionMetricName); var transactionAttribs = _transactionAttribMaker.GetAttributes(immutableTransaction, transactionMetricName, TimeSpan.FromSeconds(1), immutableTransaction.Duration, metricStatsCollection); // ACT var spanEvents = _spanEventMaker.GetSpanEvents(immutableTransaction, TransactionName, transactionAttribs); var spanEvent = spanEvents.ToList()[1]; var rootSpanEvent = spanEvents.ToList()[0]; // ASSERT Assert.AreEqual(W3cParentId, (string)rootSpanEvent.IntrinsicAttributes()["parentId"]); Assert.AreEqual(DistributedTraceGuid, (string)rootSpanEvent.IntrinsicAttributes()["trustedParentId"]); Assert.AreEqual($"{Vendor1},{Vendor2}", (string)rootSpanEvent.IntrinsicAttributes()["tracingVendors"]); }
private ImmutableTransaction BuildTestTransaction(List <Segment> segments, bool sampled, bool hasIncomingPayload) { var builder = new ImmutableTransactionBuilder() .IsWebTransaction("foo", "bar") .WithPriority(Priority) .WithDistributedTracing(DistributedTraceGuid, DistributedTraceTraceId, sampled, hasIncomingPayload) .WithSegments(segments) .WithStartTime(_startTime) .WithTransactionGuid(_transactionGuid); var segmentWithError = segments.FirstOrDefault(s => s.ErrorData != null); if (segmentWithError != null) { builder.WithExceptionFromSegment(segmentWithError); } return(builder.Build()); }