コード例 #1
0
        public async Task <IEnumerable <string> > CollectAsync(CancellationToken cancellationToken)
        {
            var configSetName = _configSetNameProvider.GetConfigSetName();
            var collectorMode = _collectorModeProvider.GetCollectorMode();

            var mode = collectorMode.ToString().ToLowerInvariant();

            try
            {
                IEnumerable <string> result;

                _logger.LogInformation($"[{configSetName}] Started {mode}ing data collections.");

                var watch = System.Diagnostics.Stopwatch.StartNew();
                try
                {
                    result = await _collector.CollectAsync(cancellationToken);
                }
                finally
                {
                    watch.Stop();
                }

                var failedDataCollectionNames = result.Any() ? " (" + string.Join(",", result) + ")" : null;

                _logger.LogInformation($"[{configSetName}] {ResultPrefix(!result.Any())} {mode}ing data collections{failedDataCollectionNames}. Elapsed time: {watch.Elapsed}");

                return(result);
            }
            catch (Exception e)
            {
                _logger.LogCritical($"[{configSetName}] " + ResultPrefix(false) + " {mode}ing data collections: {errorMessage}", mode, e.GetAggregateMessages());
                throw;
            }
        }
コード例 #2
0
        public async Task <int> MainAsync(CancellationToken cancellationToken, Action <IBootstrapper> bootstrap = null)
        {
            try
            {
                bootstrap?.Invoke(_bootstrapper);

                if (_timeFilterProcessor.TimeFilterAccepted(_timeFilterProvider.GetTimeFilter()))
                {
                    await _mainCollector.CollectAsync(cancellationToken);
                }

                return(DelayedExitCode(0, 5));
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
                return(DelayedExitCode(1, 5));
            }
        }
コード例 #3
0
 public async Task CollectAsync(string configSetName, [FromQuery] string dataCollections, [FromQuery] string collectorMode, [FromQuery] string timeFilter, CancellationToken cancellationToken)
 {
     _bootstrapper.SetConfig(configSetName, dataCollections, collectorMode, timeFilter);
     await _mainCollector.CollectAsync(cancellationToken);
 }