-
-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathSentryAspNetOptionsExtensions.cs
More file actions
44 lines (36 loc) · 1.67 KB
/
SentryAspNetOptionsExtensions.cs
File metadata and controls
44 lines (36 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using Sentry.AspNet.Internal;
using Sentry.Extensibility;
using Sentry.Infrastructure;
using Sentry.Internal;
namespace Sentry.AspNet;
/// <summary>
/// SentryOptions extensions.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static class SentryAspNetOptionsExtensions
{
/// <summary>
/// Adds ASP.NET classic integration.
/// </summary>
public static SentryOptions AddAspNet(this SentryOptions options, RequestSize maxRequestBodySize = RequestSize.None)
{
if (options.EventProcessors.Any(processor => processor.Type == typeof(SystemWebRequestEventProcessor)))
{
options.LogWarning($"{nameof(AddAspNet)} has already been called. Subsequent call will be ignored.");
return options;
}
var payloadExtractor = new RequestBodyExtractionDispatcher(
new IRequestPayloadExtractor[] { new FormRequestPayloadExtractor(), new DefaultRequestPayloadExtractor() },
options,
() => maxRequestBodySize);
var eventProcessor = new SystemWebRequestEventProcessor(payloadExtractor, options);
// Ignore options.IsGlobalModeEnable, we always want to use HttpContext as backing store here
options.ScopeStackContainer = new HttpContextScopeStackContainer();
options.DiagnosticLogger ??= new TraceDiagnosticLogger(options.DiagnosticLevel);
options.Release ??= SystemWebVersionLocator.Resolve(options, HttpContext.Current);
options.AddEventProcessor(eventProcessor);
options.AddDiagnosticSourceIntegration();
options.AddTransactionProcessor(new TraceIgnoreStatusCodeTransactionProcessor(options));
return options;
}
}