public SentryDotNetMiddleware(RequestDelegate next, ISentryClient client, SentryDotNetOptions options) { _next = next; _client = client; _options = options; if (client?.Dsn == null) { Console.WriteLine("SentryClient has been disabled, exceptions won't be captured"); } }
public static SentryEventBuilder AddRequestInformation( this SentryEventBuilder builder, HttpContext context, SentryDotNetOptions options) { var request = context.Request; builder.Request = new HttpSentryContext { Url = $"{request.Scheme}://{request.Host}{request.Path}", Method = request.Method.ToUpper(CultureInfo.InvariantCulture), QueryString = request.QueryString.ToString(), Headers = request.Headers.ToDictionary(h => h.Key, h => h.Value.ToString()), Env = new Dictionary <string, string> { { "REMOTE_ADDR", context.Connection.RemoteIpAddress.ToString() } }, Data = options.CaptureRequestBody ? ReadBody(request, options) : null }; return(builder); }
private static object ReadBody(HttpRequest request, SentryDotNetOptions options) { return(options.CaptureRequestBodyConverter(request)); }
public static IApplicationBuilder UseSentryDotNet(this IApplicationBuilder app, SentryDotNetOptions options = null) { if (app == null) { throw new ArgumentNullException(nameof(app)); } return(app.UseMiddleware <SentryDotNetMiddleware>(options ?? new SentryDotNetOptions())); }