public TransactionTraceAttributes(IAttributeValueCollection attribValues)
            {
                var filteredAttribs = new AttributeValueCollection(attribValues, AttributeDestinations.TransactionTrace);

                filteredAttribs.MakeImmutable();

                AgentAttributes = new ReadOnlyDictionary <string, object>(filteredAttribs.GetAttributeValuesDic(AttributeClassification.AgentAttributes));
                Intrinsics      = new ReadOnlyDictionary <string, object>(filteredAttribs.GetAttributeValuesDic(AttributeClassification.Intrinsics));
                UserAttributes  = new ReadOnlyDictionary <string, object>(filteredAttribs.GetAttributeValuesDic(AttributeClassification.UserAttributes));
            }
            public ErrorTraceAttributesWireModel(IAttributeValueCollection attribValues, IList <string> stackTrace = null)
            {
                var filteredAttribValues = new AttributeValueCollection(attribValues, AttributeDestinations.ErrorTrace);

                filteredAttribValues.MakeImmutable();

                AgentAttributes = new ReadOnlyDictionary <string, object>(filteredAttribValues.GetAttributeValuesDic(AttributeClassification.AgentAttributes));
                Intrinsics      = new ReadOnlyDictionary <string, object>(filteredAttribValues.GetAttributeValuesDic(AttributeClassification.Intrinsics));
                UserAttributes  = new ReadOnlyDictionary <string, object>(filteredAttribValues.GetAttributeValuesDic(AttributeClassification.UserAttributes));

                if (stackTrace != null)
                {
                    StackTrace = new ReadOnlyCollection <string>(stackTrace);
                }
            }
Esempio n. 3
0
        public void GetSpanEvent_DoesNotIncludesErrorAttributes_WhenThereIsAnError_IfErrorCollectionIsDisabled()
        {
            // ARRANGE
            _localConfig.errorCollector.enabled = false;
            PublishConfig();
            var testError = new ErrorData("error message", "ErrorType", "stack trace", DateTime.UtcNow, null, false);
            var segments  = new List <Segment>()
            {
                _baseGenericSegment.CreateSimilar(TimeSpan.FromMilliseconds(1), TimeSpan.FromMilliseconds(5), new List <KeyValuePair <string, object> >())
            };

            segments[0].ErrorData = testError;
            var immutableTransaction  = BuildTestTransaction(segments, sampled: true, hasIncomingPayload: true);
            var transactionMetricName = _transactionMetricNameMaker.GetTransactionMetricName(immutableTransaction.TransactionName);
            var metricStatsCollection = new TransactionMetricStatsCollection(transactionMetricName);
            var transactionAttributes = _transactionAttribMaker.GetAttributes(immutableTransaction, transactionMetricName, TimeSpan.FromSeconds(1), immutableTransaction.Duration, metricStatsCollection);

            // ACT
            var spanEvents           = _spanEventMaker.GetSpanEvents(immutableTransaction, TransactionName, transactionAttributes).ToList();
            var spanEvent            = spanEvents[1];
            var rootSpanEvent        = spanEvents[0];
            var errorEventAttributes = new AttributeValueCollection(transactionAttributes, AttributeDestinations.ErrorEvent);

            // ASSERT
            NrAssert.Multiple(
                () => CollectionAssert.DoesNotContain(errorEventAttributes.GetAttributeValuesDic(AttributeClassification.Intrinsics).Keys, "spanId"),
                () => CollectionAssert.DoesNotContain(spanEvent.AgentAttributes().Keys, "error.class"),
                () => CollectionAssert.DoesNotContain(rootSpanEvent.AgentAttributes().Keys, "error.class")
                );
        }