/// <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(); } }
/// <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)); }
/// <summary> /// Initializes a new instance of the <see cref="RequestData"/> class. /// </summary> /// <param name="packet">The JsonPacket to send with the request</param> /// <param name="logScrubber">The log scrubber to use, if any.</param> internal RequestData(JsonPacket packet, IScrubber logScrubber) { JsonPacket = packet ?? throw new ArgumentNullException(nameof(packet)); LogScrubber = logScrubber; }