Ejemplo 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, null)
 {
 }
Ejemplo n.º 2
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));
 }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
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)
 {
 }
 /// <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;
 }
Ejemplo 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>
        /// <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>();
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Gets the user.
 /// </summary>
 /// <returns>
 /// If an HTTP context is available, an instance of <see cref="SentryUser"/>, otherwise <c>null</c>.
 /// </returns>
 public static SentryUser GetUser(ISentryUserFactory factory)
 {
     return factory != null ? factory.Create() : null;
 }
Ejemplo 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>
        /// <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>();
        }
 /// <summary>
 /// Gets the user.
 /// </summary>
 /// <returns>
 /// If an HTTP context is available, an instance of <see cref="SentryUser"/>, otherwise <c>null</c>.
 /// </returns>
 public static SentryUser GetUser(ISentryUserFactory factory)
 {
     return(factory != null?factory.Create() : null);
 }
Ejemplo n.º 10
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);
 }
Ejemplo n.º 11
0
 public TestableRavenClient(string dsn, IJsonPacketFactory jsonPacketFactory = null, ISentryRequestFactory requestFactory = null, ISentryUserFactory userFactory = null)
     : base(dsn, jsonPacketFactory, requestFactory, userFactory)
 {
 }
Ejemplo n.º 12
0
        public IRavenClient GetTestableRavenClient(string project, ISentryRequestFactory requestFactory = null, ISentryUserFactory userFactory = null)
        {
            var jsonPacketFactory = new TestableJsonPacketFactory(project);

            return(new TestableRavenClient(dsnUri, jsonPacketFactory, requestFactory, userFactory));
        }