예제 #1
0
        public async Task HomeIndexTransactionWithToggleRecording(bool withDiagnosticSourceOnly)
        {
            _agent = new ApmAgent(new TestAgentComponents(
                                      _logger, new MockConfigSnapshot(recording: "false"), _capturedPayload));

            Configure(true, withDiagnosticSourceOnly);

            var response = await _client.GetAsync("/Home/Index");

            response.IsSuccessStatusCode.Should().BeTrue();

            _capturedPayload.Transactions.Should().BeNullOrEmpty();
            _capturedPayload.Spans.Should().BeNullOrEmpty();
            _capturedPayload.Errors.Should().BeNullOrEmpty();

            //flip recording to true
            _agent.ConfigStore.CurrentSnapshot = new MockConfigSnapshot(recording: "true");

            response = await _client.GetAsync("/Home/Index");

            response.IsSuccessStatusCode.Should().BeTrue();

            _capturedPayload.ResetTransactionTaskCompletionSource();

            _capturedPayload.Transactions.Should().NotBeEmpty();
            _capturedPayload.Spans.Should().NotBeEmpty();
            _capturedPayload.Errors.Should().BeNullOrEmpty();
        }