Exemple #1
0
        /// <summary>
        /// Lowest-level Creator of a <see cref="HttpWebResponse"/> - full
        /// control over setting every parameter that can be passed into <see cref="HttpWebResponse"/>'s
        /// constructor, except <see cref="_responseUri"/> and <see cref="_method"/> which were provided
        /// in the constructor.  Use
        /// <see cref="HttpWebResponseCreator.Create(Uri,string,HttpStatusCode,Stream,WebHeaderCollection,DecompressionMethods,string,Nullable{long},string,bool,bool,bool,string)"/>
        /// if you need to set those as well
        /// </summary>
        /// <param name="statusCode">
        /// Sets <see cref="HttpWebResponse.StatusCode"/>
        /// </param>
        /// <param name="responseStream">
        /// Sets <see cref="HttpWebResponse.GetResponseStream"/>
        /// </param>
        /// <param name="responseHeaders">
        /// Sets <see cref="HttpWebResponse.Headers"/>.
        /// Use this to also set Cookies via <see cref="HttpResponseHeader.SetCookie"/>.
        /// </param>
        /// <param name="decompressionMethod">
        /// OPTIONAL: Controls if <see cref="HttpWebResponse"/> will decompress
        /// <paramref name="responseStream"/> in its constructor.
        /// Default is <see cref="DecompressionMethods.None"/>
        /// </param>
        /// <param name="mediaType">
        /// OPTIONAL:  If <see cref="HttpWebRequest.MediaType"/> is set, you
        /// should probably pass that value in here so the correct
        /// <see cref="HttpWebResponse.ContentType"/>  response header is processed
        /// and set.
        /// Default is <c>null</c>
        /// </param>
        /// <param name="contentLength">
        /// OPTIONAL: Set/override <see cref="HttpWebResponse.ContentLength"/>.
        /// If this is null, I'll just pull the length from <paramref name="responseStream"/>,
        /// thus this is necessary to set if <paramref name="responseStream"/> doesn't support
        /// getting its length
        /// </param>
        /// <param name="statusDescription">
        /// OPTIONAL: Set <see cref="HttpWebResponse.StatusDescription"/>.
        /// Default is <c>null</c>
        /// </param>
        /// <param name="isVersionHttp11">
        /// OPTIONAL: Set <see cref="HttpWebResponse.ProtocolVersion"/>
        /// Default is <c>true</c>
        /// </param>
        /// <param name="usesProxySemantics">
        /// OPTIONAL: Influences HttpWebResponse.KeepAlive
        /// but not really sure how.
        /// Default is <c>false</c>.
        /// </param>
        /// <param name="isWebSocket">
        /// OPTIONAL: Default is <c>false</c>
        /// </param>
        /// <param name="connectionGroupName">
        /// OPTIONAL: Default is <c>null</c>
        /// </param>

        public HttpWebResponse Create(
            HttpStatusCode statusCode,
            Stream responseStream,
            WebHeaderCollection responseHeaders,
            DecompressionMethods?decompressionMethod = null,
            string mediaType           = null,
            long?contentLength         = null,
            string statusDescription   = null,
            bool isVersionHttp11       = true,
            bool usesProxySemantics    = false,
            bool isWebSocket           = false,
            string connectionGroupName = null)
        {
            return(HttpWebResponseCreator.Create(
                       _responseUri,
                       _method,
                       statusCode,
                       responseStream,
                       responseHeaders,
                       decompressionMethod ?? _automaticDecompression,
                       mediaType,
                       contentLength,
                       statusDescription,
                       isVersionHttp11,
                       usesProxySemantics,
                       isWebSocket,
                       connectionGroupName));
        }
Exemple #2
0
 /// <summary>
 /// Add Sentry Serilog Sink.
 /// </summary>
 /// <param name="loggerConfiguration">The logger configuration .<seealso cref="LoggerSinkConfiguration"/></param>
 /// <param name="dsn">The Sentry DSN. <seealso cref="SentryOptions.Dsn"/></param>
 /// <param name="minimumEventLevel">Minimum log level to send an event. <seealso cref="SentrySerilogOptions.MinimumEventLevel"/></param>
 /// <param name="minimumBreadcrumbLevel">Minimum log level to record a breadcrumb. <seealso cref="SentrySerilogOptions.MinimumBreadcrumbLevel"/></param>
 /// <param name="formatProvider">The Serilog format provider. <seealso cref="IFormatProvider"/></param>
 /// <param name="textFormatter">The Serilog text formatter. <seealso cref="ITextFormatter"/></param>
 /// <param name="sendDefaultPii">Whether to include default Personal Identifiable information. <seealso cref="SentryOptions.SendDefaultPii"/></param>
 /// <param name="isEnvironmentUser">Whether to report the <see cref="System.Environment.UserName"/> as the User affected in the event. <seealso cref="SentryOptions.IsEnvironmentUser"/></param>
 /// <param name="serverName">Gets or sets the name of the server running the application. <seealso cref="SentryOptions.ServerName"/></param>
 /// <param name="attachStackTrace">Whether to send the stack trace of a event captured without an exception. <seealso cref="SentryOptions.AttachStacktrace"/></param>
 /// <param name="maxBreadcrumbs">Gets or sets the maximum breadcrumbs. <seealso cref="SentryOptions.MaxBreadcrumbs"/></param>
 /// <param name="sampleRate">The rate to sample events. <seealso cref="SentryOptions.SampleRate"/></param>
 /// <param name="release">The release version of the application. <seealso cref="SentryOptions.Release"/></param>
 /// <param name="environment">The environment the application is running. <seealso cref="SentryOptions.Environment"/></param>
 /// <param name="maxQueueItems">The maximum number of events to keep while the worker attempts to send them. <seealso cref="SentryOptions.MaxQueueItems"/></param>
 /// <param name="shutdownTimeout">How long to wait for events to be sent before shutdown. <seealso cref="SentryOptions.ShutdownTimeout"/></param>
 /// <param name="decompressionMethods">Decompression methods accepted. <seealso cref="SentryOptions.DecompressionMethods"/></param>
 /// <param name="requestBodyCompressionLevel">The level of which to compress the <see cref="SentryEvent"/> before sending to Sentry. <seealso cref="SentryOptions.RequestBodyCompressionLevel"/></param>
 /// <param name="requestBodyCompressionBuffered">Whether the body compression is buffered and the request 'Content-Length' known in advance. <seealso cref="SentryOptions.RequestBodyCompressionBuffered"/></param>
 /// <param name="debug">Whether to log diagnostics messages. <seealso cref="SentryOptions.Debug"/></param>
 /// <param name="diagnosticLevel">The diagnostics level to be used. <seealso cref="SentryOptions.DiagnosticLevel"/></param>
 /// <param name="reportAssemblies">Whether or not to include referenced assemblies in each event sent to sentry. Defaults to <see langword="true"/>. <seealso cref="SentryOptions.ReportAssemblies"/></param>
 /// <param name="deduplicateMode">What modes to use for event automatic de-duplication. <seealso cref="SentryOptions.DeduplicateMode"/></param>
 /// <param name="initializeSdk">Whether to initialize this SDK through this integration. <seealso cref="SentrySerilogOptions.InitializeSdk"/></param>
 /// <param name="defaultTags">Defaults tags to add to all events. <seealso cref="SentryOptions.DefaultTags"/></param>
 /// <returns><see cref="LoggerConfiguration"/></returns>
 /// <example>This sample shows how each item may be set from within a configuration file:
 /// <code>
 /// {
 ///     "Serilog": {
 ///         "Using": [
 ///             "Serilog",
 ///             "Sentry",
 ///         ],
 ///         "WriteTo": [{
 ///                 "Name": "Sentry",
 ///                 "Args": {
 ///                     "dsn": "https://[email protected]",
 ///                     "minimumBreadcrumbLevel": "Verbose",
 ///                     "minimumEventLevel": "Error",
 ///                     "outputTemplate": "{Timestamp:o} [{Level:u3}] ({Application}/{MachineName}/{ThreadId}) {Message}{NewLine}{Exception}"///
 ///                     "sendDefaultPii": false,
 ///                     "isEnvironmentUser": false,
 ///                     "serverName": "MyServerName",
 ///                     "attachStackTrace": false,
 ///                     "maxBreadcrumbs": 20,
 ///                     "sampleRate": 0.5,
 ///                     "release": "0.0.1",
 ///                     "environment": "staging",
 ///                     "maxQueueItems": 100,
 ///                     "shutdownTimeout": "00:00:05",
 ///                     "decompressionMethods": "GZip",
 ///                     "requestBodyCompressionLevel": "NoCompression",
 ///                     "requestBodyCompressionBuffered": false,
 ///                     "debug": false,
 ///                     "diagnosticLevel": "Debug",
 ///                     "reportAssemblies": false,
 ///                     "deduplicateMode": "All",
 ///                     "initializeSdk": true,
 ///                     "defaultTags": {
 ///                         "key-1", "value-1",
 ///                         "key-2", "value-2"
 ///                     }
 ///                 }
 ///             }
 ///         ]
 ///     }
 /// }
 /// </code>
 /// </example>
 public static LoggerConfiguration Sentry(
     this LoggerSinkConfiguration loggerConfiguration,
     string?dsn = null,
     LogEventLevel minimumBreadcrumbLevel = LogEventLevel.Information,
     LogEventLevel minimumEventLevel      = LogEventLevel.Error,
     IFormatProvider?formatProvider       = null,
     ITextFormatter?textFormatter         = null,
     bool?sendDefaultPii      = null,
     bool?isEnvironmentUser   = null,
     string?serverName        = null,
     bool?attachStackTrace    = null,
     int?maxBreadcrumbs       = null,
     float?sampleRate         = null,
     string?release           = null,
     string?environment       = null,
     int?maxQueueItems        = null,
     TimeSpan?shutdownTimeout = null,
     DecompressionMethods?decompressionMethods    = null,
     CompressionLevel?requestBodyCompressionLevel = null,
     bool?requestBodyCompressionBuffered          = null,
     bool?debug = null,
     SentryLevel?diagnosticLevel     = null,
     bool?reportAssemblies           = null,
     DeduplicateMode?deduplicateMode = null,
     bool?initializeSdk = null,
     Dictionary <string, string>?defaultTags = null)
 {
     return(loggerConfiguration.Sentry(o => ConfigureSentrySerilogOptions(o,
                                                                          dsn,
                                                                          minimumEventLevel,
                                                                          minimumBreadcrumbLevel,
                                                                          formatProvider,
                                                                          textFormatter,
                                                                          sendDefaultPii,
                                                                          isEnvironmentUser,
                                                                          serverName,
                                                                          attachStackTrace,
                                                                          maxBreadcrumbs,
                                                                          sampleRate,
                                                                          release,
                                                                          environment,
                                                                          maxQueueItems,
                                                                          shutdownTimeout,
                                                                          decompressionMethods,
                                                                          requestBodyCompressionLevel,
                                                                          requestBodyCompressionBuffered,
                                                                          debug,
                                                                          diagnosticLevel,
                                                                          reportAssemblies,
                                                                          deduplicateMode,
                                                                          initializeSdk,
                                                                          defaultTags)));
 }
Exemple #3
0
 /// <summary>
 /// Create a new <see cref="HttpWebResponse"/>
 /// such that <see cref="HttpWebResponse.GetResponseStream"/>
 /// returns <paramref name="responseStream"/>.
 /// </summary>
 /// <param name="responseStream">
 /// Sets <see cref="HttpWebResponse.GetResponseStream"/>
 /// </param>
 /// <param name="statusCode">
 /// OPTIONAL: Sets <see cref="HttpWebResponse.StatusCode"/>.
 /// Defaults to <see cref="HttpStatusCode.OK"/>.
 /// </param>
 /// <param name="responseHeaders">
 /// OPTIONAL: Set <see cref="HttpWebResponse.Headers"/>.
 /// Defaults to an empty <see cref="WebHeaderCollection"/>
 /// <para />
 /// Use this to also set Cookies via <see cref="HttpResponseHeader.SetCookie"/>
 /// </param>
 /// <param name="decompressionMethod">
 /// OPTIONAL: Controls if <see cref="HttpWebResponse"/> will decompress
 /// <paramref name="responseStream"/> in its constructor.
 /// Default is <see cref="DecompressionMethods.None"/>
 /// </param>
 /// <param name="contentLength">
 /// OPTIONAL: Set/override <see cref="HttpWebResponse.ContentLength"/>.
 /// If this is null, I'll just pull the length from <paramref name="responseStream"/>,
 /// thus this is necessary to set if <paramref name="responseStream"/> doesn't support
 /// getting its length
 /// </param>
 public HttpWebResponse Create(
     Stream responseStream,
     HttpStatusCode statusCode                = HttpStatusCode.OK,
     WebHeaderCollection responseHeaders      = null,
     DecompressionMethods?decompressionMethod = null,
     long?contentLength = null)
 {
     return(HttpWebResponseCreator.Create(
                _responseUri,
                _method,
                statusCode,
                responseStream,
                responseHeaders ?? new WebHeaderCollection(),
                decompressionMethod ?? _automaticDecompression,
                contentLength: contentLength));
 }
Exemple #4
0
 //这里的参数表示示是否需要释放那些实现IDisposable接口的托管对象
 protected virtual void Dispose(bool disposing)
 {
     if (_disposed)
     {
         return; //如果已经被回收,就中断执行
     }
     if (disposing)
     {
         //TODO:释放那些实现IDisposable接口的托管对象
     }
     //释放非托管资源,设置对象为null
     _headers = null;
     _cookieContainerBuilder = null;
     _automaticDecompression = null;
     _uri      = null;
     _disposed = true;
 }
Exemple #5
0
        /// <summary>
        /// Configure the Sentry Serilog Sink.
        /// </summary>
        /// <param name="sentrySerilogOptions">The logger configuration to configure with the given parameters.</param>
        /// <param name="dsn">The Sentry DSN. <seealso cref="SentryOptions.Dsn"/></param>
        /// <param name="minimumEventLevel">Minimum log level to send an event. <seealso cref="SentrySerilogOptions.MinimumEventLevel"/></param>
        /// <param name="minimumBreadcrumbLevel">Minimum log level to record a breadcrumb. <seealso cref="SentrySerilogOptions.MinimumBreadcrumbLevel"/></param>
        /// <param name="formatProvider">The Serilog format provider. <seealso cref="IFormatProvider"/></param>
        /// <param name="sendDefaultPii">Whether to include default Personal Identifiable information. <seealso cref="SentryOptions.SendDefaultPii"/></param>
        /// <param name="isEnvironmentUser">Whether to report the <see cref="System.Environment.UserName"/> as the User affected in the event. <seealso cref="SentryOptions.IsEnvironmentUser"/></param>
        /// <param name="serverName">Gets or sets the name of the server running the application. <seealso cref="SentryOptions.ServerName"/></param>
        /// <param name="attachStackTrace">Whether to send the stack trace of a event captured without an exception. <seealso cref="SentryOptions.AttachStacktrace"/></param>
        /// <param name="maxBreadcrumbs">Gets or sets the maximum breadcrumbs. <seealso cref="SentryOptions.MaxBreadcrumbs"/></param>
        /// <param name="sampleRate">The rate to sample events. <seealso cref="SentryOptions.SampleRate"/></param>
        /// <param name="release">The release version of the application. <seealso cref="SentryOptions.Release"/></param>
        /// <param name="environment">The environment the application is running. <seealso cref="SentryOptions.Environment"/></param>
        /// <param name="maxQueueItems">The maximum number of events to keep while the worker attempts to send them. <seealso cref="SentryOptions.MaxQueueItems"/></param>
        /// <param name="shutdownTimeout">How long to wait for events to be sent before shutdown. <seealso cref="SentryOptions.ShutdownTimeout"/></param>
        /// <param name="decompressionMethods">Decompression methods accepted. <seealso cref="SentryOptions.DecompressionMethods"/></param>
        /// <param name="requestBodyCompressionLevel">The level of which to compress the <see cref="SentryEvent"/> before sending to Sentry. <seealso cref="SentryOptions.RequestBodyCompressionLevel"/></param>
        /// <param name="requestBodyCompressionBuffered">Whether the body compression is buffered and the request 'Content-Length' known in advance. <seealso cref="SentryOptions.RequestBodyCompressionBuffered"/></param>
        /// <param name="debug">Whether to log diagnostics messages. <seealso cref="SentryOptions.Debug"/></param>
        /// <param name="diagnosticsLevel">The diagnostics level to be used. <seealso cref="SentryOptions.DiagnosticsLevel"/></param>
        /// <param name="reportAssemblies">Whether or not to include referenced assemblies in each event sent to sentry. Defaults to <see langword="true"/>. <seealso cref="SentryOptions.ReportAssemblies"/></param>
        /// <param name="deduplicateMode">What modes to use for event automatic de-duplication. <seealso cref="SentryOptions.DeduplicateMode"/></param>
        /// <param name="initializeSdk">Whether to initialize this SDK through this integration. <seealso cref="SentrySerilogOptions.InitializeSdk"/></param>
        public static void ConfigureSentrySerilogOptions(
            SentrySerilogOptions sentrySerilogOptions,
            string?dsn = null,
            LogEventLevel?minimumEventLevel      = null,
            LogEventLevel?minimumBreadcrumbLevel = null,
            IFormatProvider?formatProvider       = null,
            bool?sendDefaultPii      = null,
            bool?isEnvironmentUser   = null,
            string?serverName        = null,
            bool?attachStackTrace    = null,
            int?maxBreadcrumbs       = null,
            float?sampleRate         = null,
            string?release           = null,
            string?environment       = null,
            int?maxQueueItems        = null,
            TimeSpan?shutdownTimeout = null,
            DecompressionMethods?decompressionMethods    = null,
            CompressionLevel?requestBodyCompressionLevel = null,
            bool?requestBodyCompressionBuffered          = null,
            bool?debug = null,
            SentryLevel?diagnosticsLevel    = null,
            bool?reportAssemblies           = null,
            DeduplicateMode?deduplicateMode = null,
            bool?initializeSdk = null)
        {
            if (!string.IsNullOrWhiteSpace(dsn))
            {
                sentrySerilogOptions.Dsn = dsn;
            }

            if (minimumEventLevel.HasValue)
            {
                sentrySerilogOptions.MinimumEventLevel = minimumEventLevel.Value;
            }

            if (minimumBreadcrumbLevel.HasValue)
            {
                sentrySerilogOptions.MinimumBreadcrumbLevel = minimumBreadcrumbLevel.Value;
            }

            if (formatProvider != null)
            {
                sentrySerilogOptions.FormatProvider = formatProvider;
            }

            if (sendDefaultPii.HasValue)
            {
                sentrySerilogOptions.SendDefaultPii = sendDefaultPii.Value;
            }

            if (isEnvironmentUser.HasValue)
            {
                sentrySerilogOptions.IsEnvironmentUser = isEnvironmentUser.Value;
            }

            if (!string.IsNullOrWhiteSpace(serverName))
            {
                sentrySerilogOptions.ServerName = serverName;
            }

            if (attachStackTrace.HasValue)
            {
                sentrySerilogOptions.AttachStacktrace = attachStackTrace.Value;
            }

            if (maxBreadcrumbs.HasValue)
            {
                sentrySerilogOptions.MaxBreadcrumbs = maxBreadcrumbs.Value;
            }

            if (sampleRate.HasValue)
            {
                sentrySerilogOptions.SampleRate = sampleRate;
            }

            if (!string.IsNullOrWhiteSpace(release))
            {
                sentrySerilogOptions.Release = release;
            }

            if (!string.IsNullOrWhiteSpace(environment))
            {
                sentrySerilogOptions.Environment = environment;
            }

            if (maxQueueItems.HasValue)
            {
                sentrySerilogOptions.MaxQueueItems = maxQueueItems.Value;
            }

            if (shutdownTimeout.HasValue)
            {
                sentrySerilogOptions.ShutdownTimeout = shutdownTimeout.Value;
            }

            if (decompressionMethods.HasValue)
            {
                sentrySerilogOptions.DecompressionMethods = decompressionMethods.Value;
            }

            if (requestBodyCompressionLevel.HasValue)
            {
                sentrySerilogOptions.RequestBodyCompressionLevel = requestBodyCompressionLevel.Value;
            }

            if (requestBodyCompressionBuffered.HasValue)
            {
                sentrySerilogOptions.RequestBodyCompressionBuffered = requestBodyCompressionBuffered.Value;
            }

            if (debug.HasValue)
            {
                sentrySerilogOptions.Debug = debug.Value;
            }

            if (diagnosticsLevel.HasValue)
            {
                sentrySerilogOptions.DiagnosticsLevel = diagnosticsLevel.Value;
            }

            if (reportAssemblies.HasValue)
            {
                sentrySerilogOptions.ReportAssemblies = reportAssemblies.Value;
            }

            if (deduplicateMode.HasValue)
            {
                sentrySerilogOptions.DeduplicateMode = deduplicateMode.Value;
            }

            // Serilog-specific items
            if (initializeSdk.HasValue)
            {
                sentrySerilogOptions.InitializeSdk = initializeSdk.Value;
            }
        }
Exemple #6
0
    /// <summary>
    /// Configure the Sentry Serilog Sink.
    /// </summary>
    /// <param name="sentrySerilogOptions">The logger configuration to configure with the given parameters.</param>
    /// <param name="dsn">The Sentry DSN. <seealso cref="SentryOptions.Dsn"/></param>
    /// <param name="minimumEventLevel">Minimum log level to send an event. <seealso cref="SentrySerilogOptions.MinimumEventLevel"/></param>
    /// <param name="minimumBreadcrumbLevel">Minimum log level to record a breadcrumb. <seealso cref="SentrySerilogOptions.MinimumBreadcrumbLevel"/></param>
    /// <param name="formatProvider">The Serilog format provider. <seealso cref="IFormatProvider"/></param>
    /// <param name="textFormatter">The Serilog text formatter. <seealso cref="ITextFormatter"/></param>
    /// <param name="sendDefaultPii">Whether to include default Personal Identifiable information. <seealso cref="SentryOptions.SendDefaultPii"/></param>
    /// <param name="isEnvironmentUser">Whether to report the <see cref="System.Environment.UserName"/> as the User affected in the event. <seealso cref="SentryOptions.IsEnvironmentUser"/></param>
    /// <param name="serverName">Gets or sets the name of the server running the application. <seealso cref="SentryOptions.ServerName"/></param>
    /// <param name="attachStackTrace">Whether to send the stack trace of a event captured without an exception. <seealso cref="SentryOptions.AttachStacktrace"/></param>
    /// <param name="maxBreadcrumbs">Gets or sets the maximum breadcrumbs. <seealso cref="SentryOptions.MaxBreadcrumbs"/></param>
    /// <param name="sampleRate">The rate to sample events. <seealso cref="SentryOptions.SampleRate"/></param>
    /// <param name="release">The release version of the application. <seealso cref="SentryOptions.Release"/></param>
    /// <param name="environment">The environment the application is running. <seealso cref="SentryOptions.Environment"/></param>
    /// <param name="maxQueueItems">The maximum number of events to keep while the worker attempts to send them. <seealso cref="SentryOptions.MaxQueueItems"/></param>
    /// <param name="shutdownTimeout">How long to wait for events to be sent before shutdown. <seealso cref="SentryOptions.ShutdownTimeout"/></param>
    /// <param name="decompressionMethods">Decompression methods accepted. <seealso cref="SentryOptions.DecompressionMethods"/></param>
    /// <param name="requestBodyCompressionLevel">The level of which to compress the <see cref="SentryEvent"/> before sending to Sentry. <seealso cref="SentryOptions.RequestBodyCompressionLevel"/></param>
    /// <param name="requestBodyCompressionBuffered">Whether the body compression is buffered and the request 'Content-Length' known in advance. <seealso cref="SentryOptions.RequestBodyCompressionBuffered"/></param>
    /// <param name="debug">Whether to log diagnostics messages. <seealso cref="SentryOptions.Debug"/></param>
    /// <param name="diagnosticLevel">The diagnostics level to be used. <seealso cref="SentryOptions.DiagnosticLevel"/></param>
    /// <param name="reportAssemblies">Whether or not to include referenced assemblies in each event sent to sentry. Defaults to <see langword="true"/>. <seealso cref="SentryOptions.ReportAssemblies"/></param>
    /// <param name="deduplicateMode">What modes to use for event automatic de-duplication. <seealso cref="SentryOptions.DeduplicateMode"/></param>
    /// <param name="initializeSdk">Whether to initialize this SDK through this integration. <seealso cref="SentrySerilogOptions.InitializeSdk"/></param>
    /// <param name="defaultTags">Defaults tags to add to all events. <seealso cref="SentryOptions.DefaultTags"/></param>
    public static void ConfigureSentrySerilogOptions(
        SentrySerilogOptions sentrySerilogOptions,
        string?dsn = null,
        LogEventLevel?minimumEventLevel      = null,
        LogEventLevel?minimumBreadcrumbLevel = null,
        IFormatProvider?formatProvider       = null,
        ITextFormatter?textFormatter         = null,
        bool?sendDefaultPii      = null,
        bool?isEnvironmentUser   = null,
        string?serverName        = null,
        bool?attachStackTrace    = null,
        int?maxBreadcrumbs       = null,
        float?sampleRate         = null,
        string?release           = null,
        string?environment       = null,
        int?maxQueueItems        = null,
        TimeSpan?shutdownTimeout = null,
        DecompressionMethods?decompressionMethods    = null,
        CompressionLevel?requestBodyCompressionLevel = null,
        bool?requestBodyCompressionBuffered          = null,
        bool?debug = null,
        SentryLevel?diagnosticLevel     = null,
        bool?reportAssemblies           = null,
        DeduplicateMode?deduplicateMode = null,
        bool?initializeSdk = null,
        Dictionary <string, string>?defaultTags = null)
    {
        if (!string.IsNullOrWhiteSpace(dsn))
        {
            sentrySerilogOptions.Dsn = dsn;
        }

        if (minimumEventLevel.HasValue)
        {
            sentrySerilogOptions.MinimumEventLevel = minimumEventLevel.Value;
        }

        if (minimumBreadcrumbLevel.HasValue)
        {
            sentrySerilogOptions.MinimumBreadcrumbLevel = minimumBreadcrumbLevel.Value;
        }

        if (formatProvider != null)
        {
            sentrySerilogOptions.FormatProvider = formatProvider;
        }

        if (textFormatter != null)
        {
            sentrySerilogOptions.TextFormatter = textFormatter;
        }

        if (sendDefaultPii.HasValue)
        {
            sentrySerilogOptions.SendDefaultPii = sendDefaultPii.Value;
        }

        if (isEnvironmentUser.HasValue)
        {
            sentrySerilogOptions.IsEnvironmentUser = isEnvironmentUser.Value;
        }

        if (!string.IsNullOrWhiteSpace(serverName))
        {
            sentrySerilogOptions.ServerName = serverName;
        }

        if (attachStackTrace.HasValue)
        {
            sentrySerilogOptions.AttachStacktrace = attachStackTrace.Value;
        }

        if (maxBreadcrumbs.HasValue)
        {
            sentrySerilogOptions.MaxBreadcrumbs = maxBreadcrumbs.Value;
        }

        if (sampleRate.HasValue)
        {
            sentrySerilogOptions.SampleRate = sampleRate;
        }

        if (!string.IsNullOrWhiteSpace(release))
        {
            sentrySerilogOptions.Release = release;
        }

        if (!string.IsNullOrWhiteSpace(environment))
        {
            sentrySerilogOptions.Environment = environment;
        }

        if (maxQueueItems.HasValue)
        {
            sentrySerilogOptions.MaxQueueItems = maxQueueItems.Value;
        }

        if (shutdownTimeout.HasValue)
        {
            sentrySerilogOptions.ShutdownTimeout = shutdownTimeout.Value;
        }

        if (decompressionMethods.HasValue)
        {
            sentrySerilogOptions.DecompressionMethods = decompressionMethods.Value;
        }

        if (requestBodyCompressionLevel.HasValue)
        {
            sentrySerilogOptions.RequestBodyCompressionLevel = requestBodyCompressionLevel.Value;
        }

        if (requestBodyCompressionBuffered.HasValue)
        {
            sentrySerilogOptions.RequestBodyCompressionBuffered = requestBodyCompressionBuffered.Value;
        }

        if (debug.HasValue)
        {
            sentrySerilogOptions.Debug = debug.Value;
        }

        if (diagnosticLevel.HasValue)
        {
            sentrySerilogOptions.DiagnosticLevel = diagnosticLevel.Value;
        }

        if (reportAssemblies.HasValue)
        {
#pragma warning disable CS0618 // Type or member is obsolete
            sentrySerilogOptions.ReportAssemblies = reportAssemblies.Value;
#pragma warning restore CS0618 // Type or member is obsolete
        }

        if (deduplicateMode.HasValue)
        {
            sentrySerilogOptions.DeduplicateMode = deduplicateMode.Value;
        }

        // Serilog-specific items
        if (initializeSdk.HasValue)
        {
            sentrySerilogOptions.InitializeSdk = initializeSdk.Value;
        }

        if (defaultTags?.Any() == true)
        {
            foreach (var tag in defaultTags)
            {
                sentrySerilogOptions.DefaultTags.Add(tag.Key, tag.Value);
            }
        }
    }
Exemple #7
0
 public AsyncHttpClient AutomaticDecompression(DecompressionMethods automaticDecompression)
 {
     _automaticDecompression = automaticDecompression;
     return(this);
 }