コード例 #1
0
        /// <inheritdoc />
        public async Task <bool> InitializeAsync(IAgentLogPluginContext context)
        {
            try
            {
                _logger        = new TraceLogger(context);
                _clientFactory = new ClientFactory(context.VssConnection);

                PopulatePipelineConfig(context);

                if (CheckForPluginDisable(context))
                {
                    return(false); // disable the plugin
                }

                await InputDataParser.InitializeAsync(_clientFactory, _pipelineConfig, _logger);
            }
            catch (Exception ex)
            {
                _logger.Warning($"Unable to initialize {FriendlyName}");
                context.Trace(ex.ToString());
                return(false);
            }

            return(true);
        }
コード例 #2
0
        /// <inheritdoc />
        public async Task <bool> InitializeAsync(IAgentLogPluginContext context)
        {
            try
            {
                _logger    = _logger ?? new TraceLogger(context);
                _telemetry = _telemetry ?? new TelemetryDataCollector(new ClientFactory(context.VssConnection), _logger);

                await PopulatePipelineConfig(context);

                if (DisablePlugin(context))
                {
                    _telemetry.AddOrUpdate(TelemetryConstants.PluginDisabled, true);
                    await _telemetry.PublishCumulativeTelemetryAsync();

                    return(false); // disable the plugin
                }

                _testFilePublisher = _testFilePublisher ??
                                     new TestFilePublisher(context.VssConnection, PipelineConfig, new TestFileTraceListener(context), _logger, _telemetry);
                await _testFilePublisher.InitializeAsync();

                _telemetry.AddOrUpdate(TelemetryConstants.PluginInitialized, true);
            }
            catch (SocketException ex)
            {
                ExceptionsUtil.HandleSocketException(ex, context.VssConnection.Uri.ToString(), _logger.Warning);

                if (_telemetry != null)
                {
                    _telemetry.AddOrUpdate(TelemetryConstants.PluginDisabled, true);
                    _telemetry.AddOrUpdate(TelemetryConstants.InitializeFailed, ex);
                    await _telemetry.PublishCumulativeTelemetryAsync();
                }
                return(false);
            }
            catch (Exception ex)
            {
                context.Trace(ex.ToString());
                _logger?.Warning($"Unable to initialize {FriendlyName}.");
                if (_telemetry != null)
                {
                    _telemetry.AddOrUpdate(TelemetryConstants.PluginDisabled, true);
                    _telemetry.AddOrUpdate(TelemetryConstants.InitializeFailed, ex);
                    await _telemetry.PublishCumulativeTelemetryAsync();
                }
                return(false);
            }

            return(true);
        }
コード例 #3
0
        /// <inheritdoc />
        public async Task <bool> InitializeAsync(IAgentLogPluginContext context)
        {
            try
            {
                _logger        = _logger ?? new TraceLogger(context);
                _clientFactory = new ClientFactory(context.VssConnection);
                _telemetry     = _telemetry ?? new TelemetryDataCollector(_clientFactory, _logger);

                await PopulatePipelineConfig(context);

                if (DisablePlugin(context))
                {
                    _telemetry.AddOrUpdate(TelemetryConstants.PluginDisabled, true);
                    await _telemetry.PublishCumulativeTelemetryAsync();

                    return(false); // disable the plugin
                }

                await _inputDataParser.InitializeAsync(_clientFactory, _pipelineConfig, _logger, _telemetry);

                _telemetry.AddOrUpdate(TelemetryConstants.PluginInitialized, true);
            }
            catch (Exception ex)
            {
                context.Trace(ex.ToString());
                _logger?.Warning($"Unable to initialize {FriendlyName}.");
                if (_telemetry != null)
                {
                    _telemetry?.AddOrUpdate(TelemetryConstants.InitialzieFailed, ex);
                    await _telemetry.PublishCumulativeTelemetryAsync();
                }
                return(false);
            }

            return(true);
        }