示例#1
0
        public IBackgroundWorker CreateBackgroundWorker()
        {
            if (_options.BackgroundWorker is IBackgroundWorker worker)
            {
                _options.DiagnosticLogger?.LogDebug("Using IBackgroundWorker set through options: {0}.",
                                                    worker.GetType().Name);

                return(worker);
            }

            var addAuth = SentryHeaders.AddSentryAuth(
                _options.SentryVersion,
                _options.ClientVersion,
                _options.Dsn.PublicKey,
                _options.Dsn.SecretKey);

            if (_options.SentryHttpClientFactory is ISentryHttpClientFactory factory)
            {
                _options.DiagnosticLogger?.LogDebug("Using ISentryHttpClientFactory set through options: {0}.",
                                                    factory.GetType().Name);
            }
            else
            {
                factory = new DefaultSentryHttpClientFactory(_options.ConfigureHandler, _options.ConfigureClient);
            }

            var httpClient = factory.Create(_options.Dsn, _options);

            return(new BackgroundWorker(new HttpTransport(_options, httpClient, addAuth), _options));
        }
示例#2
0
        public IBackgroundWorker CreateBackgroundWorker()
        {
            if (_options.BackgroundWorker is { } worker)
            {
                _options.DiagnosticLogger?.LogDebug("Using IBackgroundWorker set through options: {0}.",
                                                    worker.GetType().Name);

                return(worker);
            }

            if (_options.Dsn is null)
            {
                throw new InvalidOperationException("The DSN is expected to be set at this point.");
            }

            var dsn = Dsn.Parse(_options.Dsn);

            var addAuth = SentryHeaders.AddSentryAuth(
                _options.SentryVersion,
                _options.ClientVersion,
                dsn.PublicKey,
                dsn.SecretKey
                );

            if (_options.SentryHttpClientFactory is {})
示例#3
0
        private static HttpTransport CreateHttpTransport(
            ISentryHttpClientFactory sentryHttpClientFactory,
            SentryOptions options,
            HttpOptions httpOptions)
        {
            var addAuth = SentryHeaders.AddSentryAuth(
                options.SentryVersion,
                options.ClientVersion,
                options.Dsn.PublicKey,
                options.Dsn.SecretKey);

            var httpClient = sentryHttpClientFactory.Create(options.Dsn, httpOptions);

            return(new HttpTransport(
                       httpOptions,
                       httpClient,
                       addAuth));
        }