public Task Handle(BatchSubmissionCompletedEvent notification, CancellationToken cancellationToken)
        {
            using (var scope = TracingExtensions.StartServerSpan(
                       _tracer,
                       notification.TracingKeys,
                       "batch-submission-completion"))
            {
                try
                {
                    _logger.LogInformation(
                        "Batch submission completion handled - URI: {BatchUri}",
                        notification.BatchUri);
                }
                catch (Exception e)
                {
                    scope.Span.Log(new Dictionary <string, object>()
                    {
                        { "exception", e }
                    });
                    Tags.Error.Set(scope.Span, true);
                }

                return(Task.CompletedTask);
            }
        }
Пример #2
0
        public Task Handle(BatchSubmissionCompletedEvent notification, CancellationToken cancellationToken)
        {
            using (var scope = TracingExtensions.StartServerSpan(
                       _tracer,
                       notification.TracingKeys,
                       "batch-vetting-initiating"))
            {
                try
                {
                    _logger.LogInformation(
                        "Batch vetting initiated - URI: {BatchUri}",
                        notification.BatchUri);

                    var batchJobData = new BatchJobData
                    {
                        BatchUri    = notification.BatchUri,
                        TracingKeys = notification.TracingKeys
                    };

                    _backgroundJobClient
                    .Enqueue <VetBatchJob>(
                        job => job.Execute(batchJobData, null, JobCancellationToken.Null));
                }
                catch (Exception e)
                {
                    scope.Span.Log(new Dictionary <string, object>()
                    {
                        { "exception", e }
                    });
                    Tags.Error.Set(scope.Span, true);
                }

                return(Task.CompletedTask);
            }
        }
Пример #3
0
        public void HttpResponseMessageAsFormattedStringHandlesEmptyRequests()
        {
            using (var httpRequest = new HttpResponseMessage())
            {
                var formattedString = TracingExtensions.AsFormattedString(httpRequest);

                Assert.Contains("StatusCode: 200", formattedString);
            }
        }
Пример #4
0
        public void HttpRequestMessageAsFormattedStringHandlesEmptyRequests()
        {
            using (var httpRequest = new HttpRequestMessage())
            {
                var formattedString = TracingExtensions.AsFormattedString(httpRequest);

                Assert.Contains("Method: GET", formattedString);
            }
        }
Пример #5
0
        public void HttpResponseMessageAsFormattedStringHandlesRequestsWithHeaders()
        {
            using (var httpRequest = new HttpResponseMessage(HttpStatusCode.OK))
            {
                httpRequest.Headers.Add("x-ms-version", "2013-11-01");
                var formattedString = TracingExtensions.AsFormattedString(httpRequest);

                Assert.Contains("StatusCode: 200", formattedString);
                Assert.Contains("x-ms-version: 2013-11-01", formattedString);
            }
        }
Пример #6
0
        public void DictionaryAsFormattedStringWorksWithNulls()
        {
            var parameters = new Dictionary <string, object>();

            parameters["a"] = 1;
            parameters["b"] = "str";
            parameters["c"] = null;
            var formattedString = TracingExtensions.AsFormattedString(parameters);

            Assert.Equal("{a=1,b=str,c=}", formattedString);
        }
Пример #7
0
        public void DictionaryAsFormattedStringReturnsSet()
        {
            var parameters = new Dictionary <string, object>();

            parameters["a"] = 1;
            parameters["b"] = "str";
            parameters["c"] = true;
            var formattedString = TracingExtensions.AsFormattedString(parameters);

            Assert.Equal("{a=1,b=str,c=True}", formattedString);
        }
Пример #8
0
        public void HttpResponseMessageAsFormattedStringHandlesRequestsWithContent()
        {
            using (var httpRequest = new HttpResponseMessage(HttpStatusCode.OK))
            {
                httpRequest.Content = new StringContent("<body/>");
                var formattedString = TracingExtensions.AsFormattedString(httpRequest);

                Assert.Contains("StatusCode: 200", formattedString);
                Assert.Contains("<body/>", formattedString);
            }
        }
Пример #9
0
        public void HttpRequestMessageAsFormattedStringHandlesRequestsWithContent()
        {
            using (var httpRequest = new HttpRequestMessage(HttpMethod.Get, "http://www.windowsazure.com/test"))
            {
                httpRequest.Content = new StringContent("<body/>");
                var formattedString = TracingExtensions.AsFormattedString(httpRequest);

                Assert.Contains("Method: GET", formattedString);
                Assert.Contains("RequestUri: 'http://www.windowsazure.com/test'", formattedString);
                Assert.Contains("<body/>", formattedString);
            }
        }
Пример #10
0
        public void HttpRequestMessageAsFormattedStringHandlesRequestsWithHeaders()
        {
            using (var httpRequest = new HttpRequestMessage(HttpMethod.Get, "http://www.windowsazure.com/test"))
            {
                httpRequest.Headers.Add("x-ms-version", "2013-11-01");
                var formattedString = TracingExtensions.AsFormattedString(httpRequest);

                Assert.Contains("Method: GET", formattedString);
                Assert.Contains("RequestUri: 'http://www.windowsazure.com/test'", formattedString);
                Assert.Contains("x-ms-version: 2013-11-01", formattedString);
            }
        }
Пример #11
0
        public async Task Execute(BatchJobData batchJobData, PerformContext context, IJobCancellationToken cancellationToken)
        {
            using (TracingExtensions.StartServerSpan(_tracer, batchJobData.TracingKeys, "batch-submission-feedback-generation"))
            {
                context.WriteLine($"Generating feedback doc for batch {batchJobData.BatchId}");

                var batch = await _batchRepository.BatchForIdAsync(batchJobData.BatchId);

                var feedbackUri = _batchUriGenerator.GenerateSubmissionFeedbackUri(batch.GetBatchUri);

                await batch.GenerateSubmissionFeedbackAsync(
                    feedbackUri,
                    _batchSubmissionFeedbackStoreService);

                await _batchRepository.SaveChangesAsync(cancellationToken.ShutdownToken);
            }
        }
Пример #12
0
        public async Task Execute(BatchJobData batchJobData, PerformContext context, IJobCancellationToken cancellationToken)
        {
            using (TracingExtensions.StartServerSpan(_tracer, batchJobData.TracingKeys, "batch-vetting-job"))
            {
                context.WriteLine($"Generating feedback doc for batch {batchJobData.BatchUri}");

                var batch = await Batch.CreateAsync(
                    batchJobData.BatchUri,
                    _batchContentService);

                _batchRepository.AddBatch(batch);

                await _batchRepository.SaveChangesAsync(cancellationToken.ShutdownToken);

                await batch.Vet(
                    _batchReportUriGenerator.GenerateVettingReportUri(batch.GetBatchUri),
                    _vettingPlugins,
                    _batchVettingReportStoreService);

                await _batchRepository.SaveChangesAsync(cancellationToken.ShutdownToken);
            }
        }
Пример #13
0
 public void HttpResponseMessageAsFormattedStringThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => TracingExtensions.AsFormattedString((HttpResponseMessage)null));
 }
Пример #14
0
        public void DictionaryAsFormattedStringReturnsEmptyBracesForEmptySet()
        {
            var formattedString = TracingExtensions.AsFormattedString(new Dictionary <string, object>());

            Assert.Equal("{}", formattedString);
        }
Пример #15
0
        public void DictionaryAsFormattedStringReturnsEmptyBracesForNull()
        {
            var formattedString = TracingExtensions.AsFormattedString((Dictionary <string, object>)null);

            Assert.Equal("{}", formattedString);
        }