Example #1
0
        public void Test()
        {
            Assert.Contains("NREUM", _browserTimingHeader);

            var browserMonitoringConfig = JavaScriptAgent.GetJavaScriptAgentConfigFromSource(_browserTimingHeader);

            NrAssert.Multiple(
                () => Assert.Contains("beacon", browserMonitoringConfig.Keys),
                () => Assert.Contains("errorBeacon", browserMonitoringConfig.Keys),
                () => Assert.Contains("licenseKey", browserMonitoringConfig.Keys),
                () => Assert.Contains("applicationID", browserMonitoringConfig.Keys),
                () => Assert.Contains("transactionName", browserMonitoringConfig.Keys),
                () => Assert.Contains("queueTime", browserMonitoringConfig.Keys),
                () => Assert.Contains("applicationTime", browserMonitoringConfig.Keys),
                () => Assert.Contains("agent", browserMonitoringConfig.Keys),
                () => Assert.Contains("atts", browserMonitoringConfig.Keys)
                );
            var attrsDict = HeaderEncoder.DecodeAndDeserialize <Dictionary <string, IDictionary <string, object> > >(browserMonitoringConfig["atts"], _fixture.TestConfiguration.LicenseKey, 13);

            Assert.Contains("a", attrsDict.Keys);
            IDictionary <string, object> agentAttrsDict = attrsDict["a"];

            Assert.Contains("nr.tripId", agentAttrsDict.Keys);

            NrAssert.Multiple(
                () => Assert.NotNull(browserMonitoringConfig["beacon"]),
                () => Assert.NotNull(browserMonitoringConfig["errorBeacon"]),
                () => Assert.NotNull(browserMonitoringConfig["licenseKey"]),
                () => Assert.NotNull(browserMonitoringConfig["applicationID"]),
                () => Assert.NotNull(browserMonitoringConfig["transactionName"]),
                () => Assert.NotNull(browserMonitoringConfig["queueTime"]),
                () => Assert.NotNull(browserMonitoringConfig["applicationTime"]),
                () => Assert.NotNull(browserMonitoringConfig["agent"])
                );
        }
Example #2
0
        public void Test()
        {
            var transactionEvent = _fixture.AgentLog.TryGetTransactionEvent("WebTransaction/StatusCode/301");

            Assert.NotNull(transactionEvent);
            transactionEvent = _fixture.AgentLog.TryGetTransactionEvent("WebTransaction/StatusCode/400");
            Assert.NotNull(transactionEvent);
            transactionEvent = _fixture.AgentLog.TryGetTransactionEvent("WebTransaction/StatusCode/500");
            Assert.NotNull(transactionEvent);

            NrAssert.Multiple(
                () => Assert.Contains("NREUM", _responseBodyForHtmlContent),
                () => Assert.DoesNotContain("NREUM", _responseBodyForNonHtmlContent)
                );

            var browserMonitoringConfig = JavaScriptAgent.GetJavaScriptAgentConfigFromSource(_responseBodyForHtmlContent);

            NrAssert.Multiple(
                () => Assert.Contains("beacon", browserMonitoringConfig.Keys),
                () => Assert.Contains("errorBeacon", browserMonitoringConfig.Keys),
                () => Assert.Contains("licenseKey", browserMonitoringConfig.Keys),
                () => Assert.Contains("applicationID", browserMonitoringConfig.Keys),
                () => Assert.Contains("transactionName", browserMonitoringConfig.Keys),
                () => Assert.Contains("queueTime", browserMonitoringConfig.Keys),
                () => Assert.Contains("applicationTime", browserMonitoringConfig.Keys),
                () => Assert.Contains("agent", browserMonitoringConfig.Keys)

                // "atts" will be missing if there are no javascript attributes
                //() => Assert.Contains("atts", browserMonitoringConfig.Keys)

                // It's not guaranteed that "sslForHttp" will be present (depends on configuration)
                //() => Assert.Contains("sslForHttp", browserMonitoringConfig.Keys)
                );

            NrAssert.Multiple(
                () => Assert.NotNull(browserMonitoringConfig["beacon"]),
                () => Assert.NotNull(browserMonitoringConfig["errorBeacon"]),
                () => Assert.NotNull(browserMonitoringConfig["licenseKey"]),
                () => Assert.NotNull(browserMonitoringConfig["applicationID"]),
                () => Assert.NotNull(browserMonitoringConfig["transactionName"]),
                () => Assert.NotNull(browserMonitoringConfig["queueTime"]),
                () => Assert.NotNull(browserMonitoringConfig["applicationTime"]),
                () => Assert.NotNull(browserMonitoringConfig["agent"])

                //() => Assert.NotNull(browserMonitoringConfig["agent"]),
                //() => Assert.NotNull(browserMonitoringConfig["agent"])
                );
        }
        public void Test()
        {
            var expectedMetrics = new List <Assertions.ExpectedMetric>
            {
                new Assertions.ExpectedMetric {
                    metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"Supportability/AnalyticsEvents/TotalEventsCollected", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"HttpDispatcher", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"WebTransaction", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"WebTransactionTotalTime", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"WebTransactionTotalTime/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/AuthenticateRequest", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/AuthorizeRequest", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/ResolveRequestCache", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/MapRequestHandler", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/AcquireRequestState", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/ExecuteRequestHandler", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/DefaultController/Index", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/ReleaseRequestState", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/UpdateRequestCache", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/EndRequest", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
            };
            var unexpectedMetrics = new List <Assertions.ExpectedMetric>
            {
                new Assertions.ExpectedMetric {
                    metricName = @"WebTransaction/MVC/Integrated Pipeline"
                },
                new Assertions.ExpectedMetric {
                    metricName = @"WebTransaction/MVC/Default/Ignored"
                },
                new Assertions.ExpectedMetric {
                    metricName = @"OtherTransaction/Normalized/*"
                },
                new Assertions.ExpectedMetric {
                    metricName = @"OtherTransaction/all"
                },

                // The .NET agent does not have the information needed to generate this metric
                new Assertions.ExpectedMetric {
                    metricName = @"CPU/WebTransaction", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"CPU/WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
            };

            var expectedTransactionTraceSegments = new List <string>
            {
                @"AuthenticateRequest",
                @"AuthorizeRequest",
                @"ResolveRequestCache",
                @"MapRequestHandler",
                @"AcquireRequestState",
                @"ExecuteRequestHandler",
                @"DotNet/DefaultController/Index",
                @"ReleaseRequestState",
                @"UpdateRequestCache",
                @"EndRequest",
            };
            var expectedTransactionTraceAgentAttributes = new Dictionary <string, object>
            {
                { "response.status", "200" },
                { "http.statusCode", 200 },
                { "request.uri", "/Default" }
            };
            var expectedTransactionEventIntrinsicAttributes1 = new Dictionary <string, string>
            {
                { "type", "Transaction" }
            };
            var expectedTransactionEventIntrinsicAttributes2 = new List <string>
            {
                "timestamp",
                "duration",
                "webDuration",
                "queueDuration",
                "totalTime"
            };
            var expectedTransactionEventAgentAttributes = new Dictionary <string, object>
            {
                { "response.status", "200" },
                { "http.statusCode", 200 },
                { "request.uri", "/Default" }
            };

            var connect = _fixture.AgentLog.GetConnectData().Environment.GetPluginList();

            Assert.DoesNotContain(connect, x => x.Contains("NewRelic.Providers.Wrapper.AspNetCore"));

            var metrics = _fixture.AgentLog.GetMetrics().ToList();

            var transactionSample = _fixture.AgentLog.GetTransactionSamples()
                                    .Where(sample => sample.Path == @"WebTransaction/MVC/DefaultController/Index")
                                    .FirstOrDefault();
            var transactionEvent = _fixture.AgentLog.GetTransactionEvents()
                                   .FirstOrDefault();

            NrAssert.Multiple(
                () => Assert.NotNull(transactionSample),
                () => Assert.NotNull(transactionEvent),
                () => Assert.NotNull(_fixture.ResponseBody)
                );

            NrAssert.Multiple
            (
                () => Assertions.MetricsExist(expectedMetrics, metrics),
                () => Assertions.MetricsDoNotExist(unexpectedMetrics, metrics),
                () => Assertions.TransactionTraceSegmentsExist(expectedTransactionTraceSegments, transactionSample),
                () => Assertions.TransactionTraceHasAttributes(expectedTransactionTraceAgentAttributes, TransactionTraceAttributeType.Agent, transactionSample),
                () => Assertions.TransactionEventHasAttributes(expectedTransactionEventIntrinsicAttributes1, TransactionEventAttributeType.Intrinsic, transactionEvent),
                () => Assertions.TransactionEventHasAttributes(expectedTransactionEventIntrinsicAttributes2, TransactionEventAttributeType.Intrinsic, transactionEvent),
                () => Assertions.TransactionEventHasAttributes(expectedTransactionEventAgentAttributes, TransactionEventAttributeType.Agent, transactionEvent),
                () => JavaScriptAgent.GetJavaScriptAgentConfigFromSource(_fixture.ResponseBody),
                () => Assert.Empty(_fixture.AgentLog.GetErrorTraces()),
                () => Assert.Empty(_fixture.AgentLog.GetErrorEvents())
            );
        }
Example #4
0
        public void Test()
        {
            var expectedMetrics = new List <Assertions.ExpectedMetric>
            {
                new Assertions.ExpectedMetric {
                    metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"Supportability/AnalyticsEvents/TotalEventsCollected", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"HttpDispatcher", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"WebTransaction", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"WebTransactionTotalTime", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"WebTransactionTotalTime/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/AuthenticateRequest", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/AuthorizeRequest", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/ResolveRequestCache", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/MapRequestHandler", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/AcquireRequestState", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/ExecuteRequestHandler", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/DefaultController/Index", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/ReleaseRequestState", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/UpdateRequestCache", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"DotNet/EndRequest", metricScope = @"WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
            };
            var unexpectedMetrics = new List <Assertions.ExpectedMetric>
            {
                new Assertions.ExpectedMetric {
                    metricName = @"WebTransaction/MVC/Integrated Pipeline"
                },
                new Assertions.ExpectedMetric {
                    metricName = @"WebTransaction/MVC/Default/Ignored"
                },
                new Assertions.ExpectedMetric {
                    metricName = @"OtherTransaction/Normalized/*"
                },
                new Assertions.ExpectedMetric {
                    metricName = @"OtherTransaction/all"
                },

                // The .NET agent does not have the information needed to generate this metric
                new Assertions.ExpectedMetric {
                    metricName = @"CPU/WebTransaction", callCount = 1
                },
                new Assertions.ExpectedMetric {
                    metricName = @"CPU/WebTransaction/MVC/DefaultController/Index", callCount = 1
                },
            };

            var expectedLogLineRegexes = new List <string>
            {
                @".*No specialized async storage found. Using standard factories with CallStackManagerFactory.*"
            };

            var unexpectedLogLineRegexes = new List <string>
            {
                @".*Available storage type : NewRelic\.Providers\.Storage\.AsyncLocal.*",
                @".*Available storage type : NewRelic\.Providers\.Storage\.CallContext.*",
                @".*Using async storage.*"
            };

            var expectedTransactionTraceSegments = new List <string>
            {
                @"AuthenticateRequest",
                @"AuthorizeRequest",
                @"ResolveRequestCache",
                @"MapRequestHandler",
                @"AcquireRequestState",
                @"ExecuteRequestHandler",
                @"DotNet/DefaultController/Index",
                @"ReleaseRequestState",
                @"UpdateRequestCache",
                @"EndRequest",
            };
            var expectedTransactionTraceAgentAttributes = new Dictionary <string, object>
            {
                { "response.status", "200" },
                { "http.statusCode", 200 }
            };
            var expectedTransactionEventIntrinsicAttributes1 = new Dictionary <string, string>
            {
                { "type", "Transaction" },
                { "nr.apdexPerfZone", "F" }
            };
            var expectedTransactionEventIntrinsicAttributes2 = new List <string>
            {
                "timestamp",
                "duration",
                "webDuration",
                "queueDuration",
                "totalTime"
            };
            var expectedTransactionEventAgentAttributes = new Dictionary <string, object>
            {
                { "response.status", "200" },
                { "http.statusCode", 200 }
            };

            var metrics = _fixture.AgentLog.GetMetrics().ToList();

            var transactionSample = _fixture.AgentLog.GetTransactionSamples()
                                    .Where(sample => sample.Path == @"WebTransaction/MVC/DefaultController/Index")
                                    .FirstOrDefault();
            var transactionEvent = _fixture.AgentLog.GetTransactionEvents()
                                   .FirstOrDefault();

            NrAssert.Multiple(
                () => Assert.NotNull(transactionSample),
                () => Assert.NotNull(transactionEvent),
                () => Assert.NotNull(_fixture.ResponseBody)
                );

            NrAssert.Multiple
            (
                () => Assertions.MetricsExist(expectedMetrics, metrics),
                () => Assertions.MetricsDoNotExist(unexpectedMetrics, metrics),
                () => Assertions.TransactionTraceSegmentsExist(expectedTransactionTraceSegments, transactionSample),
                () => Assertions.TransactionTraceHasAttributes(expectedTransactionTraceAgentAttributes, TransactionTraceAttributeType.Agent, transactionSample),
                () => Assertions.TransactionEventHasAttributes(expectedTransactionEventIntrinsicAttributes1, TransactionEventAttributeType.Intrinsic, transactionEvent),
                () => Assertions.TransactionEventHasAttributes(expectedTransactionEventIntrinsicAttributes2, TransactionEventAttributeType.Intrinsic, transactionEvent),
                () => Assertions.TransactionEventHasAttributes(expectedTransactionEventAgentAttributes, TransactionEventAttributeType.Agent, transactionEvent),
                () => JavaScriptAgent.GetJavaScriptAgentConfigFromSource(_fixture.ResponseBody),
                () => Assert.Empty(_fixture.AgentLog.GetErrorTraces()),
                () => Assert.Empty(_fixture.AgentLog.GetErrorEvents()),
                () => Assertions.LogLinesExist(expectedLogLineRegexes, _fixture.AgentLog.GetFileLines()),
                () => Assertions.LogLinesNotExist(unexpectedLogLineRegexes, _fixture.AgentLog.GetFileLines())
            );
        }