Esempio n. 1
0
        public static IDisposable Init(SentryOptions options)
        {
            options.SetupLogging();

            if (options.Dsn == null)
            {
                if (!Dsn.TryParse(DsnLocator.FindDsnStringOrDisable(), out var dsn))
                {
                    options.DiagnosticLogger?.LogWarning("Init was called but no DSN was provided nor located. Sentry SDK will be disabled.");
                    return(DisabledHub.Instance);
                }
                options.Dsn = dsn;
            }

            var hub = new Hub(options);

            // Push the first scope so the async local starts from here
            hub.PushScope();

            var oldHub = Interlocked.Exchange(ref _hub, hub);

            (oldHub as IDisposable)?.Dispose();

            return(new DisposeHandle(hub));
        }
Esempio n. 2
0
        internal SentryClient(
            SentryOptions options,
            IBackgroundWorker worker)
        {
            _options = options ?? throw new ArgumentNullException(nameof(options));

            options.SetupLogging(); // Only relevant if this client wasn't created as a result of calling Init

            if (worker == null)
            {
                var composer = new SdkComposer(options);
                Worker = composer.CreateBackgroundWorker();
            }
            else
            {
                options.DiagnosticLogger?.LogDebug("Worker of type {0} was provided via Options.", worker.GetType().Name);
                Worker = worker;
            }
        }