Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RavenClient" /> class.
 /// </summary>
 /// <param name="dsn">The Data Source Name in Sentry.</param>
 /// <param name="jsonPacketFactory">The optional factory that will be used to create the <see cref="JsonPacket" /> that will be sent to Sentry.</param>
 /// <param name="sentryRequestFactory">The optional factory that will be used to create the <see cref="SentryRequest"/> that will be sent to Sentry.</param>
 /// <param name="sentryUserFactory">The optional factory that will be used to create the <see cref="SentryUser"/> that will be sent to Sentry.</param>
 public RavenClient(string dsn,
     IJsonPacketFactory jsonPacketFactory = null,
     ISentryRequestFactory sentryRequestFactory = null,
     ISentryUserFactory sentryUserFactory = null)
     : this(new Dsn(dsn), jsonPacketFactory, sentryRequestFactory, sentryUserFactory)
 {
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RavenClient" /> class.
 /// </summary>
 /// <param name="dsn">The Data Source Name in Sentry.</param>
 /// <param name="jsonPacketFactory">The optional factory that will be used to create the <see cref="JsonPacket" /> that will be sent to Sentry.</param>
 /// <param name="sentryRequestFactory">The optional factory that will be used to create the <see cref="SentryRequest"/> that will be sent to Sentry.</param>
 /// <param name="sentryUserFactory">The optional factory that will be used to create the <see cref="SentryUser"/> that will be sent to Sentry.</param>
 public RavenClient(string dsn,
                    IJsonPacketFactory jsonPacketFactory       = null,
                    ISentryRequestFactory sentryRequestFactory = null,
                    ISentryUserFactory sentryUserFactory       = null)
     : this(new Dsn(dsn), jsonPacketFactory, sentryRequestFactory, sentryUserFactory, null)
 {
 }
Esempio n. 3
0
 public TestableRavenClient(Dsn dsn, IJsonPacketFactory jsonPacketFactory)
     : base(dsn, jsonPacketFactory)
 {
     // This constructor must exist so Nancy can inject the Dsn and NancyContextJsonPacketFactory
     // that is registered in SentryRegistrations. @asbjornu
     this.dsn = dsn;
 }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SentrySink" /> class.
        /// </summary>
        /// <param name="formatProvider">The format provider.</param>
        /// <param name="dsn">The DSN.</param>
        /// <param name="release">The release.</param>
        /// <param name="environment">The environment.</param>
        /// <param name="tags">Comma separated list of properties to treat as tags in sentry.</param>
        /// <param name="jsonPacketFactory">The json packet factory.</param>
        /// <param name="sentryUserFactory">The sentry user factory.</param>
        /// <param name="sentryRequestFactory">The sentry request factory.</param>
        /// <param name="dataScrubber">
        /// An <see cref="IScrubber"/> implementation for cleaning up the data sent to Sentry
        /// </param>
        /// <param name="logger">The name of the logger used by Sentry.</param>
        /// <exception cref="ArgumentException">Value cannot be null or whitespace. - dsn</exception>
        public SentrySink(
            IFormatProvider formatProvider,
            string dsn,
            string release,
            string environment,
            string tags,
            IJsonPacketFactory jsonPacketFactory,
            ISentryUserFactory sentryUserFactory,
            ISentryRequestFactory sentryRequestFactory,
            IScrubber dataScrubber,
            string logger)
        {
            if (string.IsNullOrWhiteSpace(dsn))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(dsn));
            }

            _formatProvider       = formatProvider;
            _dsn                  = dsn;
            _release              = release;
            _environment          = environment;
            _jsonPacketFactory    = jsonPacketFactory;
            _sentryUserFactory    = sentryUserFactory;
            _sentryRequestFactory = sentryRequestFactory;
            _dataScrubber         = dataScrubber;
            _logger               = logger;

            if (!string.IsNullOrWhiteSpace(tags))
            {
                _tags = tags.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(t => t.Trim())
                        .ToArray();
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Add Sentry sink to the logger configuration.
 /// </summary>
 /// <param name="loggerConfiguration">The logger configuration.</param>
 /// <param name="dsn">The DSN.</param>
 /// <param name="release">The release.</param>
 /// <param name="environment">The environment.</param>
 /// <param name="restrictedToMinimumLevel">The restricted to minimum level.</param>
 /// <param name="formatProvider">The format provider.</param>
 /// <param name="tags">Comma separated list of properties to treat as tags in sentry.</param>
 /// <param name="jsonPacketFactory">The json packet factory.</param>
 /// <param name="sentryUserFactory">The sentry user factory.</param>
 /// <param name="sentryRequestFactory">The sentry request factory.</param>
 /// <param name="dataScrubber">An <see cref="IScrubber"/> implementation for cleaning up logs before sending to Sentry</param>
 /// <param name="logger">The name of the logger used by Sentry.</param>
 /// <returns>
 /// The logger configuration.
 /// </returns>
 // ReSharper disable once StyleCop.SA1625
 public static LoggerConfiguration Sentry(
     this LoggerSinkConfiguration loggerConfiguration,
     string dsn,
     string release     = null,
     string environment = null,
     LogEventLevel restrictedToMinimumLevel = LogEventLevel.Error,
     IFormatProvider formatProvider         = null,
     string tags = null,
     IJsonPacketFactory jsonPacketFactory       = null,
     ISentryUserFactory sentryUserFactory       = null,
     ISentryRequestFactory sentryRequestFactory = null,
     IScrubber dataScrubber = null,
     string logger          = null)
 {
     return(loggerConfiguration.Sink(
                new SentrySink(
                    formatProvider,
                    dsn,
                    release,
                    environment,
                    tags,
                    jsonPacketFactory,
                    sentryUserFactory,
                    sentryRequestFactory,
                    dataScrubber,
                    logger),
                restrictedToMinimumLevel));
 }
Esempio n. 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RavenClient" /> class.
        /// </summary>
        /// <param name="dsn">The Data Source Name in Sentry.</param>
        /// <param name="jsonPacketFactory">The optional factory that will be used to create the <see cref="JsonPacket" /> that will be sent to Sentry.</param>
        /// <exception cref="System.ArgumentNullException">dsn</exception>
        public RavenClient(Dsn dsn, IJsonPacketFactory jsonPacketFactory = null)
        {
            if (dsn == null)
                throw new ArgumentNullException("dsn");

            this.currentDsn = dsn;
            this.jsonPacketFactory = jsonPacketFactory ?? new JsonPacketFactory();
            Logger = "root";
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RavenClient" /> class.
        /// </summary>
        /// <param name="dsn">The Data Source Name in Sentry.</param>
        /// <param name="jsonPacketFactory">The optional factory that will be used to create the <see cref="JsonPacket" /> that will be sent to Sentry.</param>
        /// <exception cref="System.ArgumentNullException">dsn</exception>
        public RavenClient(Dsn dsn, IJsonPacketFactory jsonPacketFactory = null)
        {
            if (dsn == null)
                throw new ArgumentNullException("dsn");

            this.currentDsn = dsn;
            this.jsonPacketFactory = jsonPacketFactory ?? new JsonPacketFactory();
            Logger = "root";
        }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RavenClient" /> class.
        /// </summary>
        /// <param name="dsn">The Data Source Name in Sentry.</param>
        /// <param name="jsonPacketFactory">The optional factory that will be used to create the <see cref="JsonPacket" /> that will be sent to Sentry.</param>
        /// <exception cref="System.ArgumentNullException">dsn</exception>
        public RavenClient(Dsn dsn, IJsonPacketFactory jsonPacketFactory = null)
        {
            if (dsn == null)
            {
                throw new ArgumentNullException("dsn");
            }

            this.currentDsn        = dsn;
            this.jsonPacketFactory = jsonPacketFactory ?? new JsonPacketFactory();
            Logger  = "root";
            Timeout = TimeSpan.FromSeconds(5);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:SharpRaven.RavenClient" /> class.
 /// </summary>
 /// <param name="dsn">The Data Source Name in Sentry.</param>
 /// <param name="backgroundSending">Whether to send events in the background or not.</param>
 /// <param name="jsonPacketFactory">The optional factory that will be used to create the <see cref="T:SharpRaven.Data.JsonPacket" /> that will be sent to Sentry.</param>
 /// <param name="sentryRequestFactory">The optional factory that will be used to create the <see cref="T:SharpRaven.Data.SentryRequest" /> that will be sent to Sentry.</param>
 /// <param name="sentryUserFactory">The optional factory that will be used to create the <see cref="T:SharpRaven.Data.SentryUser" /> that will be sent to Sentry.</param>
 /// <inheritdoc />
 public RavenClient(Dsn dsn,
                    bool backgroundSending,
                    IJsonPacketFactory jsonPacketFactory       = null,
                    ISentryRequestFactory sentryRequestFactory = null,
                    ISentryUserFactory sentryUserFactory       = null)
     : this(
         dsn,
         jsonPacketFactory,
         sentryRequestFactory,
         sentryUserFactory,
         backgroundSending
             ? new BackgroundRequesterFactory(new HttpRequesterFactory())
             : new HttpRequesterFactory() as IRequesterFactory)
 {
     // Lifetime of RequesterFactory owned by this instance, make sure to dispose it.
     this.disposeRequesterFactory = backgroundSending;
 }
Esempio n. 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RavenClient" /> class.
        /// </summary>
        /// <param name="dsn">The Data Source Name in Sentry.</param>
        /// <param name="jsonPacketFactory">The optional factory that will be used to create the <see cref="JsonPacket" /> that will be sent to Sentry.</param>
        /// <param name="sentryRequestFactory">The optional factory that will be used to create the <see cref="SentryRequest"/> that will be sent to Sentry.</param>
        /// <param name="sentryUserFactory">The optional factory that will be used to create the <see cref="SentryUser"/> that will be sent to Sentry.</param>
        /// <exception cref="System.ArgumentNullException">dsn</exception>
        public RavenClient(Dsn dsn,
                           IJsonPacketFactory jsonPacketFactory       = null,
                           ISentryRequestFactory sentryRequestFactory = null,
                           ISentryUserFactory sentryUserFactory       = null)
        {
            if (dsn == null)
            {
                throw new ArgumentNullException("dsn");
            }

            this.currentDsn           = dsn;
            this.jsonPacketFactory    = jsonPacketFactory ?? new JsonPacketFactory();
            this.sentryRequestFactory = sentryRequestFactory ?? new SentryRequestFactory();
            this.sentryUserFactory    = sentryUserFactory ?? new SentryUserFactory();

            Logger           = "root";
            Timeout          = TimeSpan.FromSeconds(5);
            this.defaultTags = new Dictionary <string, string>();
        }
Esempio n. 11
0
 public TestableRavenClient(string dsn, IJsonPacketFactory jsonPacketFactory = null, ISentryRequestFactory requestFactory = null, ISentryUserFactory userFactory = null)
     : base(dsn, jsonPacketFactory, requestFactory, userFactory)
 {
 }
 public void SetUp()
 {
     this.jsonPacketFactory = new JsonPacketFactory();
 }
Esempio n. 13
0
 public TestableRavenClient(IJsonPacketFactory jsonPacketFactory)
     : base(jsonPacketFactory)
 {
     // This constructor must exist so Nancy can inject the NancyContextJsonPacketFactory
     // that is registered in SentryRegistrations. @asbjornu
 }
Esempio n. 14
0
 public TestableRavenClient(string dsn, IJsonPacketFactory jsonPacketFactory = null)
     : base(dsn, jsonPacketFactory)
 {
 }
Esempio n. 15
0
 public TestableRavenClient(Dsn dsn, IJsonPacketFactory jsonPacketFactory)
     : base(dsn, jsonPacketFactory)
 {
     // This constructor must exist so Nancy can inject the Dsn and NancyContextJsonPacketFactory
     // that is registered in SentryRegistrations. @asbjornu
     this.dsn = dsn;
 }
Esempio n. 16
0
 public TestableRavenClient(IJsonPacketFactory jsonPacketFactory)
     : base(jsonPacketFactory)
 {
     // This constructor must exist so Nancy can inject the NancyContextJsonPacketFactory
     // that is registered in SentryRegistrations. @asbjornu
 }
Esempio n. 17
0
 public TestableRavenClient(string dsn, IJsonPacketFactory jsonPacketFactory = null)
     : base(dsn, jsonPacketFactory)
 {
 }
Esempio n. 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RavenClient" /> class.
 /// </summary>
 /// <param name="dsn">The Data Source Name in Sentry.</param>
 /// <param name="jsonPacketFactory">The optional factory that will be used to create the <see cref="JsonPacket" /> that will be sent to Sentry.</param>
 public RavenClient(string dsn, IJsonPacketFactory jsonPacketFactory = null)
     : this(new Dsn(dsn), jsonPacketFactory)
 {
 }
Esempio n. 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RavenClient" /> class. Sentry
 /// Data Source Name will be read from sharpRaven section in your app.config or
 /// web.config.
 /// </summary>
 /// <param name="jsonPacketFactory">The optional factory that will be used to create the <see cref="JsonPacket" /> that will be sent to Sentry.</param>
 public RavenClient(IJsonPacketFactory jsonPacketFactory = null)
     : this(new Dsn(""), jsonPacketFactory)
 {
 }
Esempio n. 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RavenClient" /> class. Sentry
 /// Data Source Name will be read from sharpRaven section in your app.config or
 /// web.config.
 /// </summary>
 /// <param name="jsonPacketFactory">The optional factory that will be used to create the <see cref="JsonPacket" /> that will be sent to Sentry.</param>
 public RavenClient(IJsonPacketFactory jsonPacketFactory = null)
     : this(new Dsn(Configuration.Settings.Dsn.Value), jsonPacketFactory)
 {
 }
Esempio n. 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RavenClient" /> class. Sentry
 /// Data Source Name will be read from sharpRaven section in your app.config or
 /// web.config.
 /// </summary>
 /// <param name="jsonPacketFactory">The optional factory that will be used to create the <see cref="JsonPacket" /> that will be sent to Sentry.</param>
 public RavenClient(IJsonPacketFactory jsonPacketFactory = null)
     : this(new Dsn(Configuration.Settings.Dsn.Value), jsonPacketFactory)
 {
 }
 public RavenClientTestable(string dsnUri, IJsonPacketFactory jsonPacketFactory)
     : base(dsnUri, jsonPacketFactory)
 {
 }
Esempio n. 23
0
 /// <summary>
 /// General constructor for exception logging
 /// </summary>
 /// <param name="dsn">Sentry dsn</param>
 /// <param name="jsonPacketFactory">Sentry configuration</param>
 /// <param name="sentryRequestFactory">Sentry configuration</param>
 /// <param name="sentryUserFactory">Sentry configuration</param>
 public SentryInterceptor(Dsn dsn, IJsonPacketFactory jsonPacketFactory = null,
                          ISentryRequestFactory sentryRequestFactory    = null, ISentryUserFactory sentryUserFactory = null)
 {
     _sentryClient = new RavenClient(dsn, jsonPacketFactory, sentryRequestFactory, sentryUserFactory);
     _breadcrumber = new Breadcrumber(_sentryClient);
 }
Esempio n. 24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RavenClient" /> class.
        /// </summary>
        /// <param name="dsn">The Data Source Name in Sentry.</param>
        /// <param name="jsonPacketFactory">The optional factory that will be used to create the <see cref="JsonPacket" /> that will be sent to Sentry.</param>
        /// <param name="sentryRequestFactory">The optional factory that will be used to create the <see cref="SentryRequest"/> that will be sent to Sentry.</param>
        /// <param name="sentryUserFactory">The optional factory that will be used to create the <see cref="SentryUser"/> that will be sent to Sentry.</param>
        /// <exception cref="System.ArgumentNullException">dsn</exception>
        public RavenClient(Dsn dsn,
            IJsonPacketFactory jsonPacketFactory = null,
            ISentryRequestFactory sentryRequestFactory = null,
            ISentryUserFactory sentryUserFactory = null)
        {
            if (dsn == null)
                throw new ArgumentNullException("dsn");

            this.currentDsn = dsn;
            this.jsonPacketFactory = jsonPacketFactory ?? new JsonPacketFactory();
            this.sentryRequestFactory = sentryRequestFactory ?? new SentryRequestFactory();
            this.sentryUserFactory = sentryUserFactory ?? new SentryUserFactory();

            Logger = "root";
            Timeout = TimeSpan.FromSeconds(5);
            this.defaultTags = new Dictionary<string, string>();
        }
Esempio n. 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RavenClient" /> class.
 /// </summary>
 /// <param name="dsn">The Data Source Name in Sentry.</param>
 /// <param name="jsonPacketFactory">The optional factory that will be used to create the <see cref="JsonPacket" /> that will be sent to Sentry.</param>
 public RavenClient(string dsn, IJsonPacketFactory jsonPacketFactory = null)
     : this(new Dsn(dsn), jsonPacketFactory)
 {
 }