Esempio n. 1
0
        public async Task <MonitoringResults> GetResponseReadTimeMs(MonitoringSettings settings, Context context)
        {
            MonitoringResults results = new MonitoringResults {
                Results = new List <EndpointResult>()
            };

            // In a real app, would use a Task.WhenAll() fanout pattern.
            foreach (var endpoint in settings.Endpoints)
            {
                var watch = Stopwatch.StartNew();

                var response = await GetAsyncUsingContext(endpoint, context);

                // Returning the response read time should throw if - after all resilience attempts - we can't read and time a valid response.
                response.EnsureSuccessStatusCode();

                var contentActuallyOfNoInterest = await(response.Content?.ReadAsStringAsync() ?? Task.FromResult(String.Empty));

                results.Results.Add(new EndpointResult()
                {
                    Url = endpoint, Value = watch.ElapsedMilliseconds
                });
            }

            return(results);
        }
Esempio n. 2
0
        public async Task <MonitoringResults> GetStatus(MonitoringSettings settings, Context context)
        {
            MonitoringResults results = new MonitoringResults {
                Results = new List <EndpointResult>()
            };

            // In a real app, would use a Task.WhenAll() fanout pattern.
            foreach (var endpoint in settings.Endpoints)
            {
                var response = await GetAsyncUsingContext(endpoint, context);

                results.Results.Add(new EndpointResult()
                {
                    Url = endpoint, Value = (int)response.StatusCode
                });
            }

            return(results);
        }