Ejemplo n.º 1
0
        public BasicAspWebService(RemoteServiceFixtures.BasicAspWebService fixture, ITestOutputHelper output)
            : base(fixture)
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;
            _fixture.Actions(
                setupConfiguration: () =>
            {
                var newRelicConfig = _fixture.DestinationNewRelicConfigFilePath;
                var configModifier = new NewRelicConfigModifier(newRelicConfig);
                configModifier.ForceTransactionTraces();

                //The purpose of this custom instrumentation file is to ignore noisy transactions.
                var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml";
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "System.Web.Extensions", "System.Web.Handlers.ScriptResourceHandler", "ProcessRequest", "NewRelic.Agent.Core.Tracer.Factories.IgnoreTransactionTracerFactory");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "System.Web", "System.Web.Handlers.AssemblyResourceLoader", "GetAssemblyInfo", "NewRelic.Agent.Core.Tracer.Factories.IgnoreTransactionTracerFactory");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "System.Web.Extensions", "System.Web.Script.Services.RestClientProxyHandler", "ProcessRequest", "NewRelic.Agent.Core.Tracer.Factories.IgnoreTransactionTracerFactory");
            },
                exerciseApplication: () =>
            {
                _fixture.InvokeAsyncCall();
                _fixture.AgentLog.WaitForLogLine(AgentLogBase.TransactionSampleLogLineRegex, TimeSpan.FromMinutes(2));
            });
            _fixture.Initialize();
        }
        public ConsoleAsyncTests(ConsoleAsyncFixture fixture, ITestOutputHelper output) : base(fixture)
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;
            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                _fixture.RemoteApplication.NewRelicConfig.SetLogLevel("finest");

                var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml";

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.AsyncAwaitUseCases", "IoBoundNoSpecialAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.OtherTransactionWrapperAsync", "IoBoundNoSpecialAsync", 7);
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.AsyncAwaitUseCases", "IoBoundConfigureAwaitFalseAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.OtherTransactionWrapperAsync", "IoBoundConfigureAwaitFalseAsync", 7);
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.AsyncAwaitUseCases", "CpuBoundTasksAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.OtherTransactionWrapperAsync", "CpuBoundTasksAsync", 7);

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.AsyncAwaitUseCases", "CustomMethodAsync1", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync1");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.AsyncAwaitUseCases", "CustomMethodAsync2", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync2");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.AsyncAwaitUseCases", "CustomMethodAsync3", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync3");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.AsyncAwaitUseCases", "ConfigureAwaitFalseExampleAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ConfigureAwaitFalseExampleAsync");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.AsyncAwaitUseCases", "ConfigureAwaitSubMethodAsync2", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ConfigureAwaitSubMethodAsync2");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.AsyncAwaitUseCases", "TaskRunBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "TaskRunBackgroundMethod");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.AsyncAwaitUseCases", "TaskFactoryStartNewBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "TaskFactoryStartNewBackgroundMethod");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.ManualAsyncUseCases", "TaskRunBlocked", "MultithreadedTrackingWrapper", "TaskRunBlocked", 7);
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.ManualAsyncUseCases", "TaskFactoryStartNewBlocked", "MultithreadedTrackingWrapper", "TaskFactoryStartNewBlocked", 7);
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.ManualAsyncUseCases", "NewThreadStartBlocked", "MultithreadedTrackingWrapper", "NewThreadStartBlocked", 7);
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "ConsoleAsyncApplication", "ConsoleAsyncApplication.ManualAsyncUseCases", "MultipleThreadSegmentParenting", "MultithreadedTrackingWrapper", "MultipleThreadSegmentParenting", 7);
            }
            );
            _fixture.Initialize();
        }
        public CustomInstrumentationAsync(RemoteServiceFixtures.BasicMvcApplicationTestFixture fixture, ITestOutputHelper output)
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;
            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                var configPath     = fixture.DestinationNewRelicConfigFilePath;
                var configModifier = new NewRelicConfigModifier(configPath);
                configModifier.ForceTransactionTraces();

                var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentationAsync.xml";

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationAsyncController", "CustomMethodDefaultWrapperAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "MyCustomMetricName", 7);
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationAsyncController", "CustomSegmentTransactionSegmentWrapper", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.CustomSegmentWrapperAsync");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationAsyncController", "CustomSegmentAlternateParameterNamingTheSegment", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.CustomSegmentWrapperAsync");
            },
                exerciseApplication: () =>
            {
                _fixture.GetCustomInstrumentationAsync();
            }
            );
            _fixture.Initialize();
        }
        protected RejitChangeAttributeValueBase(TFixture fixture, ITestOutputHelper output) : base(fixture)
        {
            _fixture = fixture;

            var changeAttributeFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.ChangeAttributeTest.xml";

            _fixture.TestLogger = output;
            _fixture.Actions(
                setupConfiguration: () =>
            {
                var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath);
                configModifier.SetLogLevel("finest");
                configModifier.AutoInstrumentBrowserMonitoring(false);

                CommonUtils.AddCustomInstrumentation(changeAttributeFilePath, "AspNetCoreMvcRejitApplication", "RejitMvcApplication.Controllers.RejitController", "CustomMethodDefaultWrapperChangeAttributeValue", "NewRelic.Agent.Core.Wrapper.DefaultWrapper", "MyCustomChangeMetricName", 7);
            },
                exerciseApplication: () =>
            {
                _fixture.InitializeApp();

                _fixture.TestChangeAttributeValue();
                CommonUtils.ModifyOrCreateXmlAttribute(changeAttributeFilePath, "urn:newrelic-extension", new[] { "extension", "instrumentation", "tracerFactory" }, "metricName", "MyCustomRenamedMetricName");
                _fixture.AgentLog.WaitForLogLine(AgentLogBase.InstrumentationRefreshFileWatcherComplete, TimeSpan.FromMinutes(1));
                _fixture.TestChangeAttributeValue();
            });

            _fixture.Initialize();
        }
Ejemplo n.º 5
0
        protected RejitAddFileBase(TFixture fixture, ITestOutputHelper output) : base(fixture)
        {
            _fixture = fixture;

            _fixture.TestLogger = output;
            _fixture.Actions(
                setupConfiguration: () =>
            {
                var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath);
                configModifier.SetLogLevel("finest");
                configModifier.AutoInstrumentBrowserMonitoring(false);
            },
                exerciseApplication: () =>
            {
                _fixture.InitializeApp();

                _fixture.TestAddFile();
                var createFilePath = _fixture.RemoteApplication.DestinationNewRelicHomeDirectoryPath + @"\Integration.Testing.AddXmlFileTest.xml";
                CommonUtils.AddCustomInstrumentation(createFilePath, "AspNetCoreMvcRejitApplication", "RejitMvcApplication.Controllers.RejitController", "CustomMethodDefaultWrapperAddFile", "NewRelic.Agent.Core.Wrapper.DefaultWrapper", "MyCustomAddMetricName", 7);
                var destinationFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.AddXmlFileTest.xml";
                CommonUtils.MoveFile(createFilePath, destinationFilePath, TimeSpan.FromSeconds(5));
                _fixture.AgentLog.WaitForLogLine(AgentLogBase.InstrumentationRefreshFileWatcherComplete, TimeSpan.FromMinutes(1));
                _fixture.TestAddFile();
            });

            _fixture.Initialize();
        }
        public NetCoreAsyncTests(NetCoreAsyncTestsFixture fixture, ITestOutputHelper output)
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;
            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml";

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NetCoreAsyncApplication", "NetCoreAsyncApplication.AsyncUseCases", "IoBoundNoSpecialAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.OtherTransactionWrapperAsync", "IoBoundNoSpecialAsync", 7);
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NetCoreAsyncApplication", "NetCoreAsyncApplication.AsyncUseCases", "IoBoundConfigureAwaitFalseAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.OtherTransactionWrapperAsync", "IoBoundConfigureAwaitFalseAsync", 7);
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NetCoreAsyncApplication", "NetCoreAsyncApplication.AsyncUseCases", "CpuBoundTasksAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.OtherTransactionWrapperAsync", "CpuBoundTasksAsync", 7);

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NetCoreAsyncApplication", "NetCoreAsyncApplication.AsyncUseCases", "CustomMethodAsync1", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync1");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NetCoreAsyncApplication", "NetCoreAsyncApplication.AsyncUseCases", "CustomMethodAsync2", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync2");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NetCoreAsyncApplication", "NetCoreAsyncApplication.AsyncUseCases", "CustomMethodAsync3", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync3");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NetCoreAsyncApplication", "NetCoreAsyncApplication.AsyncUseCases", "ConfigureAwaitFalseExampleAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ConfigureAwaitFalseExampleAsync");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NetCoreAsyncApplication", "NetCoreAsyncApplication.AsyncUseCases", "ConfigureAwaitSubMethodAsync2", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ConfigureAwaitSubMethodAsync2");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NetCoreAsyncApplication", "NetCoreAsyncApplication.AsyncUseCases", "TaskRunBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "TaskRunBackgroundMethod");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NetCoreAsyncApplication", "NetCoreAsyncApplication.AsyncUseCases", "TaskFactoryStartNewBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "TaskFactoryStartNewBackgroundMethod");
            }
            );
            _fixture.Initialize();
        }
Ejemplo n.º 7
0
        public RejitAddNode(AspNetFrameworkReJitMvcApplicationFixture fixture, ITestOutputHelper output)
            : base(fixture)
        {
            _fixture = fixture;

            var addNodeFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.AddNodeTest.xml";

            _fixture.TestLogger = output;
            _fixture.Actions(
                setupConfiguration: () =>
            {
                var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath);
                configModifier.AutoInstrumentBrowserMonitoring(false);

                CommonUtils.CreateEmptyInstrumentationFile(addNodeFilePath);
            },
                exerciseApplication: () =>
            {
                _fixture.InitializeApp();

                _fixture.TestAddNode(1);     // this will cause this method require a full rejit (differnet profiler code)
                var document = CommonUtils.AddCustomInstrumentation(addNodeFilePath, "RejitMvcApplication", "RejitMvcApplication.Controllers.RejitController", "CustomMethodDefaultWrapperAddNode", "NewRelic.Agent.Core.Wrapper.DefaultWrapper", "MyCustomAddMetricName", 7, false);
                CommonUtils.AddXmlNode(addNodeFilePath, "urn:newrelic-extension", new[] { "extension", "instrumentation", "tracerFactory", "match" }, "exactMethodMatcher", string.Empty, "methodName", "CustomMethodDefaultWrapperAddNode1", false, document);
                // Potential future addition: Adding a test for new match element.  not adding now since it would require a second app to test really well.
                document.Save(addNodeFilePath);
                _fixture.AgentLog.WaitForLogLine(AgentLogBase.InstrumentationRefreshFileWatcherComplete, TimeSpan.FromMinutes(1));
                _fixture.TestAddNode(0);
                _fixture.TestAddNode(1);
            });

            _fixture.Initialize();
        }
Ejemplo n.º 8
0
        public NetStandardLibraryInstrumentation(TFixture fixture, ITestOutputHelper output) : base(fixture)
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;
            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                var configPath     = fixture.DestinationNewRelicConfigFilePath;
                var configModifier = new NewRelicConfigModifier(configPath);
                configModifier.ForceTransactionTraces();

                var instrumentationXmlFilePath = Path.Combine(fixture.DestinationNewRelicExtensionsDirectoryPath, "TestCustomInstrumetnation.xml");

                CommonUtils.AddCustomInstrumentation(
                    instrumentationFilePath: instrumentationXmlFilePath,
                    assemblyName: "NetStandardTestLibrary",
                    typeName: "NetStandardTestLibrary.NetStandardTestLibUtil",
                    methodName: "Test",
                    wrapperName: "NewRelic.Agent.Core.Tracer.Factories.BackgroundThreadTracerFactory");

                _fixture.RemoteApplication.NewRelicConfig.SetLogLevel("finest");
                _fixture.RemoteApplication.NewRelicConfig.ForceTransactionTraces();
                _fixture.RemoteApplication.NewRelicConfig.SetOrDeleteDistributedTraceEnabled(true);
                _fixture.RemoteApplication.NewRelicConfig.SetCATEnabled(false);

                _fixture.AddCommand("AssemblyHelper LoadAssemblyFromFile NetStandardTestLibrary.dll");
                _fixture.AddCommand($"NetStandardTestLibUtil Test {COUNT_ITERATIONS}");
            }
            );
            _fixture.Initialize();
        }
Ejemplo n.º 9
0
        public RejitDeleteFile(AspNetFrameworkReJitMvcApplicationFixture fixture, ITestOutputHelper output)
        {
            _fixture = fixture;

            var deleteFileFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.DeleteXmlFileTest.xml";

            _fixture.TestLogger = output;
            _fixture.Actions(
                setupConfiguration: () =>
            {
                var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath);
                configModifier.AutoInstrumentBrowserMonitoring(false);

                CommonUtils.AddCustomInstrumentation(deleteFileFilePath, "RejitMvcApplication", "RejitMvcApplication.Controllers.RejitController", "CustomMethodDefaultWrapperDeleteFile", "NewRelic.Agent.Core.Wrapper.DefaultWrapper", "MyCustomDeleteMetricName", 7);
            },
                exerciseApplication: () =>
            {
                _fixture.InitializeApp();

                _fixture.TestDeleteFile();
                CommonUtils.DeleteFile(deleteFileFilePath, TimeSpan.FromSeconds(5));
                _fixture.AgentLog.WaitForLogLine(AgentLogBase.InstrumentationRefreshFileWatcherComplete, TimeSpan.FromMinutes(1));
                _fixture.TestDeleteFile();
            });

            _fixture.Initialize();
        }
Ejemplo n.º 10
0
        public MsCorLibTests(RemoteServiceFixtures.BasicMvcApplicationTestFixture fixture, ITestOutputHelper output)
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;
            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml";

                //System.IO.Path.Combine seems to always be hit by MVC. Could move to console application w/ direct execution if ever have issues.
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "mscorlib", "System.IO.Path", "Combine");
            },
                exerciseApplication: () =>
            {
                try
                {
                    _fixture.Get();
                }
                catch (WebException ex)
                {
                    throw new Exception("Application with mscorlib custom instrumentation crashed.", ex);

                    // Due to reliance on the managed log existing for integration test execution, we can't gracefully catch
                    // then assert later in the actual test case. Would be nice to fix all of this long-term...
                    // i.e. optionally wait for logs / have other mechanisms.
                }
            }
            );
            _fixture.Initialize();
        }
Ejemplo n.º 11
0
 protected override void SetupConfiguration(string instrumentationFilePath)
 {
     CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.AsyncFireAndForgetUseCases", "SyncMethod", "AsyncForceNewTransactionWrapper");
     CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.AsyncFireAndForgetUseCases", "AsyncMethod", "AsyncForceNewTransactionWrapper");
     CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.AsyncFireAndForgetUseCases", "Async_AwaitedAsync", "OtherTransactionWrapper");
     CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.AsyncFireAndForgetUseCases", "Async_FireAndForget", "OtherTransactionWrapper");
     CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.AsyncFireAndForgetUseCases", "Async_Sync", "OtherTransactionWrapper");
     CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.AsyncFireAndForgetUseCases", "Sync_AwaitedAsync", "OtherTransactionWrapper");
     CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.AsyncFireAndForgetUseCases", "Sync_FireAndForget", "OtherTransactionWrapper");
     CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.AsyncFireAndForgetUseCases", "Sync_Sync", "OtherTransactionWrapper");
 }
        // The base test class runs tests for Owin 2; the derived classes test Owin 3 and 4
        public OwinWebApiAsyncTests(OwinWebApiFixture fixture, ITestOutputHelper output)
        {
            _fixture = fixture;
            var assemblyName = _fixture.AssemblyName;

            _fixture.TestLogger = output;
            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                var configPath = fixture.DestinationNewRelicConfigFilePath;

                var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml";

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, assemblyName, $"{assemblyName}.Controllers.AsyncAwaitController", "CustomMethodAsync1", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync1");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, assemblyName, $"{assemblyName}.Controllers.AsyncAwaitController", "CustomMethodAsync2", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync2");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, assemblyName, $"{assemblyName}.Controllers.AsyncAwaitController", "CustomMethodAsync3", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync3");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, assemblyName, $"{assemblyName}.Controllers.AsyncAwaitController", "ConfigureAwaitFalseExampleAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ConfigureAwaitFalseExampleAsync");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, assemblyName, $"{assemblyName}.Controllers.AsyncAwaitController", "ConfigureAwaitSubMethodAsync2", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ConfigureAwaitSubMethodAsync2");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, assemblyName, $"{assemblyName}.Controllers.AsyncAwaitController", "TaskRunBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "TaskRunBackgroundMethod");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, assemblyName, $"{assemblyName}.Controllers.AsyncAwaitController", "TaskFactoryStartNewBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "TaskFactoryStartNewBackgroundMethod");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, assemblyName, $"{assemblyName}.Controllers.ManualAsyncController", "TaskRunBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ManualTaskRunBackgroundMethod");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, assemblyName, $"{assemblyName}.Controllers.ManualAsyncController", "TaskFactoryStartNewBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ManualTaskFactoryStartNewBackgroundMethod");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, assemblyName, $"{assemblyName}.Controllers.ManualAsyncController", "ThreadStartBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ManualThreadStartBackgroundMethod");
            },
                exerciseApplication: () =>
            {
                _fixture.GetIoBoundNoSpecialAsync();
                _fixture.GetCustomMiddlewareIoBoundNoSpecialAsync();
                _fixture.GetIoBoundConfigureAwaitFalseAsync();
                _fixture.GetCpuBoundTasksAsync();

                _fixture.GetManualTaskRunBlocked();
                _fixture.GetManualTaskFactoryStartNewBlocked();
                _fixture.GetManualNewThreadStartBlocked();

                _fixture.ErrorResponse();

                _fixture.AgentLog.WaitForLogLine(AgentLogFile.TransactionSampleLogLineRegex, TimeSpan.FromMinutes(2));
            }
            );
            _fixture.Initialize();
        }
Ejemplo n.º 13
0
        public CustomInstrumentation(RemoteServiceFixtures.BasicMvcApplicationTestFixture fixture, ITestOutputHelper output)
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;
            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                var configPath     = fixture.DestinationNewRelicConfigFilePath;
                var configModifier = new NewRelicConfigModifier(configPath);
                configModifier.ForceTransactionTraces();

                var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml";

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationController", "CustomMethodDefaultWrapper", "NewRelic.Agent.Core.Wrapper.DefaultWrapper", "MyCustomMetricName", 7);
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationController", "CustomMethodDefaultTracer", "NewRelic.Agent.Core.Tracer.Factories.DefaultTracerFactory");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationController", "CustomMethodUnknownWrapperName", "INVALID.WRAPPER.NAME");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationController", "CustomSegmentTransactionSegmentWrapper", "NewRelic.Providers.Wrapper.CustomInstrumentation.CustomSegmentWrapper");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationController",
                                                     "CustomSegmentAlternateParameterNamingTheSegment", "NewRelic.Providers.Wrapper.CustomInstrumentation.CustomSegmentWrapper");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationController", "CustomSegmentTracer", "NewRelic.Agent.Core.Tracer.Factories.CustomSegmentTracerFactory");


                // NOTE: If no wrapperName (a.k.a. "tracerFactoryName") is specified in instrumentation then the profiler will automatically use "NewRelic.Agent.Core.Tracer.Factories.DefaultTracerFactory". This is hard-coded into the profiler.
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationController", "CustomMethodNoWrapperName");

                // Ignored transactions
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationController", "CustomMethodIgnoreTransactionWrapper", "NewRelic.Providers.Wrapper.CustomInstrumentation.IgnoreTransactionWrapper");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationController", "CustomMethodIgnoreTransactionTracerFactory", "NewRelic.Agent.Core.Tracer.Factories.IgnoreTransactionTracerFactory");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationController", "CustomMethodIgnoreTransactionWrapperAsync", "NewRelic.Providers.Wrapper.CustomInstrumentation.IgnoreTransactionWrapper");
            },
                exerciseApplication: () =>
            {
                _fixture.GetCustomInstrumentation();
                _fixture.GetIgnoredByIgnoreTransactionWrapper();
                _fixture.GetIgnoredByIgnoreTransactionTracerFactory();
                _fixture.GetIgnoredByIgnoreTransactionWrapperAsync();
            }
            );
            _fixture.Initialize();
        }
Ejemplo n.º 14
0
        public DetachWrapperTests(RemoteServiceFixtures.AspNetCoreMvcBasicRequestsFixture fixture, ITestOutputHelper output)
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;
            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\TerminatingSegmentInstrumentation.xml";

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "AspNetCoreMvcBasicRequestsApplication", "AspNetCoreMvcBasicRequestsApplication.Controllers.DetachWrapperController", "AsyncMethodWithExternalCall", "DetachWrapper");
            },
                exerciseApplication: () =>
            {
                _fixture.GetCallAsyncExternal();
            }
            );
            _fixture.Initialize();
        }
        protected RejitDeleteNodeBase(TFixture fixture, ITestOutputHelper output) : base(fixture)
        {
            _fixture = fixture;

            var deleteNodeFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.DeleteNodeTest.xml";

            _fixture.TestLogger = output;
            _fixture.Actions(
                setupConfiguration: () =>
            {
                var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath);
                configModifier.SetLogLevel("finest");
                configModifier.AutoInstrumentBrowserMonitoring(false);

                var document = CommonUtils.AddCustomInstrumentation(deleteNodeFilePath, "AspNetCoreMvcRejitApplication", "RejitMvcApplication.Controllers.RejitController", "CustomMethodDefaultWrapperDeleteNode", "NewRelic.Agent.Core.Wrapper.DefaultWrapper", "MyCustomDeleteMetricName", 7, false);
                CommonUtils.AddXmlNode(deleteNodeFilePath, "urn:newrelic-extension", new[] { "extension", "instrumentation", "tracerFactory", "match" }, "exactMethodMatcher", string.Empty, "methodName", "CustomMethodDefaultWrapperDeleteNode1", true, document);
            },
                exerciseApplication: () =>
            {
                _fixture.InitializeApp();

                _fixture.TestDeleteNode(0);
                _fixture.TestDeleteNode(1);
                CommonUtils.DeleteXmlNode(deleteNodeFilePath, "urn:newrelic-extension",
                                          new[] { "extension", "instrumentation", "tracerFactory", "match" }, "exactMethodMatcher"); // deletes first one (CustomMethodDefaultWrapperDeleteNode)
                _fixture.AgentLog.WaitForLogLine(AgentLogBase.InstrumentationRefreshFileWatcherComplete, TimeSpan.FromMinutes(1));
                _fixture.TestDeleteNode(0);
                _fixture.TestDeleteNode(1);


                // Uncommenting the following lines lead to odd metric counts. Manual testing of this scenario does not seem
                // to indicate a problem. For now, just chalking it up to timing issue with how our tests are run...

                //CommonUtils.DeleteXmlNode(_deleteNodeFilePath, "urn:newrelic-extension",
                //	new[] { "extension", "instrumentation" }, "tracerFactory");
                //_fixture.AgentLog.WaitForLogLine(AgentLogBase.InstrumentationRefreshFileWatcherComplete, TimeSpan.FromMinutes(1));
                //_fixture.TestDeleteNode(0);
                //_fixture.TestDeleteNode(1);
            });

            _fixture.Initialize();
        }
        public AsyncStreamTests(RemoteServiceFixtures.AspNetCore3FeaturesFixture fixture, ITestOutputHelper output)
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;
            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml";

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "AspNetCore3Features", "AspNetCore3Features.Controllers.AsyncStreamController", "GetNumbers");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "AspNetCore3Features", "AspNetCore3Features.Controllers.AsyncStreamController", "DoSomethingAsync");
            },
                exerciseApplication: () =>
            {
                _fixture.AsyncStream();
            }
            );
            _fixture.Initialize();
        }
Ejemplo n.º 17
0
        public OtherTransaction(RemoteServiceFixtures.AgentApiExecutor fixture, ITestOutputHelper output)
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;
            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath);

                var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml";

                //Use the two different wrappers here to ensure that they both filter to OtherTransactionWrapper and create the same behavior

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NewRelic.Agent.IntegrationTests.Applications.AgentApiExecutor", "NewRelic.Agent.IntegrationTests.Applications.AgentApiExecutor.Program", "RealMain", "NewRelic.Providers.Wrapper.CustomInstrumentation.OtherTransactionWrapper", "MyCustomMetricName");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "NewRelic.Agent.IntegrationTests.Applications.AgentApiExecutor", "NewRelic.Agent.IntegrationTests.Applications.AgentApiExecutor.Program", "SomeSlowMethod", "NewRelic.Agent.Core.Tracer.Factories.BackgroundThreadTracerFactory");
            }
            );
            _fixture.Initialize();
        }
        public OtherTransactionAsyncWithError(RemoteServiceFixtures.BasicMvcApplicationTestFixture fixture, ITestOutputHelper output) : base(fixture)
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;
            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath);
                configModifier.ForceTransactionTraces();

                var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml";

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "BasicMvcApplication", "BasicMvcApplication.Controllers.CustomInstrumentationAsyncController", "CustomMethodBackgroundThreadWithError", "AsyncForceNewTransactionWrapper");
            },
                exerciseApplication: () =>
            {
                _fixture.GetBackgroundThreadWithError();
            }
            );
            _fixture.Initialize();
        }
Ejemplo n.º 19
0
        public AspNetCoreMvcAsyncTests(AspNetCoreMvcAsyncTestsFixture fixture, ITestOutputHelper output)
            : base(fixture)
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;
            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml";

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitTestController", "CustomMethodAsync1", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync1");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitTestController", "CustomMethodAsync2", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync2");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitTestController", "CustomMethodAsync3", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "CustomMethodAsync3");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitTestController", "ConfigureAwaitFalseExampleAsync", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ConfigureAwaitFalseExampleAsync");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitTestController", "ConfigureAwaitSubMethodAsync2", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ConfigureAwaitSubMethodAsync2");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitTestController", "TaskRunBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "TaskRunBackgroundMethod");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncAwaitTestController", "TaskFactoryStartNewBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "TaskFactoryStartNewBackgroundMethod");

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.ManualAsyncController", "TaskRunBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ManualTaskRunBackgroundMethod");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.ManualAsyncController", "TaskFactoryStartNewBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ManualTaskFactoryStartNewBackgroundMethod");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.ManualAsyncController", "ThreadStartBackgroundMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync", "ManualThreadStartBackgroundMethod");
            },
                exerciseApplication: () =>
            {
                _fixture.GetIoBoundNoSpecialAsync();
                _fixture.GetCustomMiddlewareIoBoundNoSpecialAsync();
                _fixture.GetIoBoundConfigureAwaitFalseAsync();
                _fixture.GetCpuBoundTasksAsync();

                _fixture.GetManualTaskRunBlocked();
                _fixture.GetManualTaskFactoryStartNewBlocked();
                _fixture.GetManualNewThreadStartBlocked();
            }
            );
            _fixture.Initialize();
        }
Ejemplo n.º 20
0
        public InterfaceDefaultsInstrumentationTests(RemoteServiceFixtures.AspNetCore3FeaturesFixture fixture, ITestOutputHelper output)
        {
            _fixture            = fixture;
            _fixture.TestLogger = output;
            _fixture.Actions
            (
                setupConfiguration: () =>
            {
                var instrumentationFilePath = $@"{fixture.DestinationNewRelicExtensionsDirectoryPath}\CustomInstrumentation.xml";

                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "AspNetCore3Features", "AspNetCore3Features.Controllers.ILoggerNoAttributes", "LogException");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "AspNetCore3Features", "AspNetCore3Features.Controllers.ConsoleLoggerNoAttributesNoDefault", "LogMessage");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "AspNetCore3Features", "AspNetCore3Features.Controllers.ConsoleLoggerNoAttributesOverridesDefault", "LogException");
                CommonUtils.AddCustomInstrumentation(instrumentationFilePath, "AspNetCore3Features", "AspNetCore3Features.Controllers.ConsoleLoggerNoAttributesOverridesDefault", "LogMessage");
            },
                exerciseApplication: () =>
            {
                _fixture.InterfaceDefaultsGetWithAttributes();
                _fixture.InterfaceDefaultsGetWithoutAttributes();
            }
            );
            _fixture.Initialize();
        }
 protected override void SetupConfiguration(string instrumentationFilePath)
 {
     CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncFireAndForgetController", "AsyncMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapperAsync");
     CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncFireAndForgetController", "SyncMethod", "NewRelic.Providers.Wrapper.CustomInstrumentationAsync.DefaultWrapper");
 }
 protected override void SetupConfiguration(string instrumentationFilePath)
 {
     CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncFireAndForgetController", "AsyncMethod", "AsyncForceNewTransactionWrapper");
     CommonUtils.AddCustomInstrumentation(instrumentationFilePath, AssemblyName, $"{AssemblyName}.Controllers.AsyncFireAndForgetController", "SyncMethod", "AsyncForceNewTransactionWrapper");
 }