示例#1
0
 public ExcepticonExceptionInstancesService(ExcepticonOptions options)
 {
     _httpClient = new HttpClient
     {
         BaseAddress = new Uri(options.Url, UriKind.Absolute)
     };
 }
示例#2
0
        public static IDisposable Init(ExcepticonOptions options)
        {
            var exceptionInstancesService = new ExcepticonExceptionInstancesService(options);
            var queueManager = new QueueManager(exceptionInstancesService, options);

            return(UseClient(new ExcepticonClient(options, queueManager)));
        }
 public ExcepticonMiddleware(
     RequestDelegate next,
     Func <IExcepticonClient> excepticonClientAccessor,
     IOptions <ExcepticonOptions> options,
     ILogger <ExcepticonMiddleware> logger)
 {
     _next = next ?? throw new ArgumentNullException(nameof(next));
     _excepticonClientAccessor = excepticonClientAccessor ?? throw new ArgumentNullException(nameof(excepticonClientAccessor));
     _options = options?.Value;
     _logger  = logger;
 }
示例#4
0
        public ExcepticonClient(ExcepticonOptions options, IQueueManager queueManager)
        {
            QueueManager = queueManager ?? throw new ArgumentNullException(nameof(queueManager));
            _options     = options ?? throw new ArgumentNullException(nameof(options));

            _integrations = options.Integrations;
            if (_integrations?.Any() ?? false)
            {
                foreach (var integration in _integrations)
                {
                    integration.Register(this, options);
                }
            }
        }
示例#5
0
        public QueueManager(
            IExcepticonExceptionInstancesService excepticonExceptionInstancesService,
            ExcepticonOptions options,
            CancellationTokenSource shutdownSource    = null,
            ConcurrentQueue <ExceptionInstance> queue = null)
        {
            _excepticonExceptionInstancesService = excepticonExceptionInstancesService ?? throw new ArgumentNullException(nameof(excepticonExceptionInstancesService));
            _options        = options ?? throw new ArgumentNullException(nameof(options));
            _shutdownSource = shutdownSource ?? new CancellationTokenSource();
            _queue          = queue ?? new ConcurrentQueue <ExceptionInstance>();

            _queuedEventSemaphore = new SemaphoreSlim(0, _options.MaxQueueItems);

            WorkerTask = Task.Run(async() => await WorkerAsync(_shutdownSource.Token).ConfigureAwait(false));
        }
示例#6
0
        public static ILoggingBuilder AddExcepticon(
            this ILoggingBuilder builder,
            Action <ExcepticonOptions> optionsConfiguration)
        {
            var options = new ExcepticonOptions();

            optionsConfiguration?.Invoke(options);

            builder.AddConfiguration();

            if (optionsConfiguration != null)
            {
                builder.Services.Configure(optionsConfiguration);
            }

            builder.Services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            builder.Services.AddSingleton <IConfigureOptions <ExcepticonOptions>, ExcepticonLoggingOptionsSetup>();
            builder.Services.AddSingleton <ILoggerProvider, ExcepticonLoggerProvider>();
            builder.Services.AddSingleton <IExcepticonClient, ExcepticonClient>();
            builder.Services.AddSingleton <IQueueManager, QueueManager>();

            builder.Services.AddExcepticon();
            return(builder);
        }
 public ExceptionHandlingMiddleware(RequestDelegate next, ExcepticonOptions options)
 {
     _next    = next;
     _options = options ?? throw new ArgumentNullException(nameof(options));
     _exceptionInstancesExcepticonExceptionInstancesService = new ExcepticonExceptionInstancesService(options);
 }
示例#8
0
 public void Register(IExcepticonClient client, ExcepticonOptions options)
 {
     _client = client;
     _appDomain.ProcessExit += OnProcessExit;
 }