Esempio n. 1
0
        public TransactionNameTests(WebApplicationFactory <Startup> factory)
        {
            _factory = factory;

            _agent = new ApmAgent(new TestAgentComponents(payloadSender: _payloadSender,
                                                          // _agent needs to share CurrentExecutionSegmentsContainer with Agent.Instance
                                                          // because the sample application used by the tests (SampleAspNetCoreApp) uses Agent.Instance.Tracer.CurrentTransaction/CurrentSpan
                                                          currentExecutionSegmentsContainer: Agent.Instance.TracerInternal.CurrentExecutionSegmentsContainer));
            ApmMiddlewareExtension.UpdateServiceInformation(_agent.Service);
        }
Esempio n. 2
0
 public AspNetCoreMiddlewareTests(WebApplicationFactory <Startup> factory)
 {
     _factory = factory;
     //The agent is instantiated with ApmMiddlewareExtension.GetService, so we can also test the calculation of the service instance.
     //(e.g. ASP.NET Core version)
     _agent = new ApmAgent(
         new TestAgentComponents(service: ApmMiddlewareExtension.GetService(new TestAgentConfigurationReader(new TestLogger()))));
     _capturedPayload = _agent.PayloadSender as MockPayloadSender;
     _client          = Helper.GetClient(_agent, _factory);
 }
        public AspNetCoreMiddlewareTests(WebApplicationFactory <Startup> factory, ITestOutputHelper xUnitOutputHelper)
        {
            _logger  = new XunitOutputLogger(xUnitOutputHelper).Scoped(nameof(AspNetCoreMiddlewareTests));
            _factory = factory;

            //The agent is instantiated with ApmMiddlewareExtension.GetService, so we can also test the calculation of the service instance.
            //(e.g. ASP.NET Core version)
            _agent = new ApmAgent(new TestAgentComponents(new TestAgentConfigurationReader(_logger)));
            ApmMiddlewareExtension.UpdateServiceInformation(_agent.Service);

            _capturedPayload = _agent.PayloadSender as MockPayloadSender;
            _client          = Helper.GetClient(_agent, _factory);
        }
        public AspNetCoreMiddlewareTests(WebApplicationFactory <Startup> factory, ITestOutputHelper xUnitOutputHelper)
        {
            _logger  = new XunitOutputLogger(xUnitOutputHelper).Scoped(nameof(AspNetCoreMiddlewareTests));
            _factory = factory;

            // We need to ensure Agent.Instance is created because we need _agent to use Agent.Instance CurrentExecutionSegmentsContainer
            AgentSingletonUtils.EnsureInstanceCreated();
            _agent = new ApmAgent(new TestAgentComponents(logger: _logger, configurationReader: new TestAgentConfigurationReader(_logger),
                                                          // _agent needs to share CurrentExecutionSegmentsContainer with Agent.Instance
                                                          // because the sample application used by the tests (SampleAspNetCoreApp) uses Agent.Instance.Tracer.CurrentTransaction/CurrentSpan
                                                          currentExecutionSegmentsContainer: Agent.Instance.TracerInternal.CurrentExecutionSegmentsContainer));
            ApmMiddlewareExtension.UpdateServiceInformation(_agent.Service);

            _capturedPayload = _agent.PayloadSender as MockPayloadSender;
            _client          = Helper.GetClient(_agent, _factory);
        }
        public MicrosoftExtensionsConfigIntegrationTests(WebApplicationFactory <Startup> factory)
        {
            _factory         = factory;
            _logger          = new TestLogger();
            _capturedPayload = new MockPayloadSender();

            //The agent is instantiated with ApmMiddlewareExtension.GetService, so we can also test the calculation of the service instance.
            //(e.g. ASP.NET Core version)

            var config = new MicrosoftExtensionsConfig(
                MicrosoftExtensionsConfigTests.GetConfig($"TestConfigs{Path.DirectorySeparatorChar}appsettings_invalid.json"), _logger);

            _agent = new ApmAgent(
                new AgentComponents(payloadSender: _capturedPayload, configurationReader: config,
                                    service: ApmMiddlewareExtension.GetService(new TestAgentConfigurationReader(new TestLogger())), logger: _logger));
            _client = Helper.GetClient(_agent, _factory);
        }
Esempio n. 6
0
        public AspNetCoreMiddlewareTests(WebApplicationFactory <Startup> factory, ITestOutputHelper xUnitOutputHelper) : base(xUnitOutputHelper)
        {
            _logger  = LoggerBase.Scoped(ThisClassName);
            _factory = factory;

            _agent = new ApmAgent(new TestAgentComponents(
                                      _logger,
                                      new MockConfigSnapshot(_logger, captureBody: ConfigConsts.SupportedValues.CaptureBodyAll),
                                      // _agent needs to share CurrentExecutionSegmentsContainer with Agent.Instance
                                      // because the sample application used by the tests (SampleAspNetCoreApp) uses Agent.Instance.Tracer.CurrentTransaction/CurrentSpan
                                      currentExecutionSegmentsContainer: Agent.Instance.TracerInternal.CurrentExecutionSegmentsContainer)
                                  );
            ApmMiddlewareExtension.UpdateServiceInformation(_agent.Service);

            _capturedPayload = _agent.PayloadSender as MockPayloadSender;
            _client          = Helper.GetClient(_agent, _factory);
        }
 public TransactionNameTests(WebApplicationFactory <Startup> factory)
 {
     _factory = factory;
     _agent   = new ApmAgent(new TestAgentComponents(payloadSender: _payloadSender));
     ApmMiddlewareExtension.UpdateServiceInformation(_agent.Service);
 }