Beispiel #1
0
        public void ShouldNotAcceptBadStringDistributedTracePayload()
        {
            var agentWrapperApi = _compositeTestAgent.GetAgent();
            var transaction     = agentWrapperApi.CreateTransaction(
                isWeb: true,
                category: EnumNameCache <WebTransactionType> .GetName(WebTransactionType.ASP),
                transactionDisplayName: "TransactionName",
                doNotTrackAsUnitOfWork: true);
            var transactionBridgeApi = new TransactionBridgeApi(transaction, _apiSupportabilityMetricCounters, _configSvc);

            var segment = agentWrapperApi.StartTransactionSegmentOrThrow("segment");

            transactionBridgeApi.AcceptDistributedTracePayload(_badDistributedTracePayloadString, 0 /*Unknown TransportType see Agent\NewRelic.Api.Agent\TransportType.cs for more info*/);

            segment.End();
            transaction.End();

            _compositeTestAgent.Harvest();

            var expectedMetrics = new List <ExpectedMetric>
            {
                new ExpectedCountMetric {
                    Name = "Supportability/DistributedTrace/AcceptPayload/ParseException", CallCount = 1
                }
            };

            MetricAssertions.MetricsExist(expectedMetrics, _compositeTestAgent.Metrics);
        }
Beispiel #2
0
        public void ShouldAcceptStringDistributedTracePayloadWhenDTEnabled()
        {
            var agentWrapperApi = _compositeTestAgent.GetAgent();
            var transaction     = agentWrapperApi.CreateTransaction(
                isWeb: true,
                category: EnumNameCache <WebTransactionType> .GetName(WebTransactionType.ASP),
                transactionDisplayName: "TransactionName",
                doNotTrackAsUnitOfWork: true);
            var transactionBridgeApi = new TransactionBridgeApi(transaction, _apiSupportabilityMetricCounters, _configSvc);

            var segment = agentWrapperApi.StartTransactionSegmentOrThrow("segment");

            transactionBridgeApi.AcceptDistributedTracePayload(_distributedTracePayload.ToJson(), 0 /*Unknown TransportType see Agent\NewRelic.Api.Agent\TransportType.cs for more info*/);

            segment.End();
            transaction.End();

            _compositeTestAgent.Harvest();

            var transactionEvent      = _compositeTestAgent.TransactionEvents.First();
            var transactionAttributes = transactionEvent.IntrinsicAttributes();

            NrAssert.Multiple(
                () => Assert.AreEqual(_traceId, transactionAttributes["traceId"]),
                () => Assert.AreEqual(_type.ToString(), transactionAttributes["parent.type"]),
                () => Assert.AreEqual(_appId, transactionAttributes["parent.app"]),
                () => Assert.AreEqual(_accountId, transactionAttributes["parent.account"]),
                () => Assert.AreEqual("Unknown", transactionAttributes["parent.transportType"]),
                () => Assert.True(transactionAttributes.ContainsKey("parent.transportDuration")),
                () => Assert.AreEqual(_transactionId, transactionAttributes["parentId"]),
                () => Assert.AreEqual(_priority, transactionAttributes["priority"]),
                () => Assert.AreEqual(_sampled, transactionAttributes["sampled"])
                );
        }
Beispiel #3
0
        public void ShouldNotAcceptStringDistributedTracePayloadWhenDTNotEnabled()
        {
            _compositeTestAgent.LocalConfiguration.distributedTracing.enabled = false;
            _compositeTestAgent.PushConfiguration();

            var agentWrapperApi = _compositeTestAgent.GetAgent();
            var transaction     = agentWrapperApi.CreateTransaction(
                isWeb: true,
                category: EnumNameCache <WebTransactionType> .GetName(WebTransactionType.ASP),
                transactionDisplayName: "TransactionName",
                doNotTrackAsUnitOfWork: true);
            var transactionBridgeApi = new TransactionBridgeApi(transaction, _apiSupportabilityMetricCounters, _configSvc);

            var segment = agentWrapperApi.StartTransactionSegmentOrThrow("segment");

            transactionBridgeApi.AcceptDistributedTracePayload(_distributedTracePayload.ToJson(), 0 /*Unknown TransportType see Agent\NewRelic.Api.Agent\TransportType.cs for more info*/);

            segment.End();
            transaction.End();

            _compositeTestAgent.Harvest();

            var transactionEvent = _compositeTestAgent.TransactionEvents.First();

            var expectedMissingAttributes = new[]
            {
                "traceId",
                "parent.type",
                "parent.app",
                "parent.account",
                "parent.transportType",
                "parent.TransportDuration",
                "parentId",
                "priority",
                "sampled"
            };

            TransactionEventAssertions.DoesNotHaveAttributes(expectedMissingAttributes, AttributeClassification.Intrinsics, transactionEvent);
        }