protected override async Task SendAsync(Exception exception, IList <string> tags, IDictionary userCustomData) { if (CanSend(exception)) { RaygunRequestMessage currentRequestMessage = await BuildRequestMessage(); RaygunResponseMessage currentResponseMessage = BuildResponseMessage(); _currentHttpContext.Value = null; _currentRequestMessage.Value = currentRequestMessage; _currentResponseMessage.Value = currentResponseMessage; await StripAndSend(exception, tags, userCustomData, null); FlagAsSent(exception); } }
/// <summary> /// Asynchronously transmits an exception to Raygun. /// </summary> /// <param name="exception">The exception to deliver.</param> /// <param name="tags">A list of strings associated with the message.</param> /// <param name="userCustomData">A key-value collection of custom data that will be added to the payload.</param> /// <param name="userInfo">Information about the user including the identity string.</param> public override async Task SendInBackground(Exception exception, IList <string> tags, IDictionary userCustomData, RaygunIdentifierMessage userInfo) { if (CanSend(exception)) { // We need to process the Request on the current thread, // otherwise it will be disposed while we are using it on the other thread. RaygunRequestMessage currentRequestMessage = await BuildRequestMessage(); RaygunResponseMessage currentResponseMessage = BuildResponseMessage(); var task = Task.Run(async() => { _currentRequestMessage.Value = currentRequestMessage; _currentResponseMessage.Value = currentResponseMessage; await StripAndSend(exception, tags, userCustomData, userInfo); }); FlagAsSent(exception); await task; } }
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { if (logEvent.Level < _restrictedToMinimumLevel) { return; } if (_httpContextAccessor?.HttpContext == null) { return; } var options = new RaygunRequestMessageOptions { IsRawDataIgnored = _raygunSettings.IsRawDataIgnored, UseXmlRawDataFilter = _raygunSettings.UseXmlRawDataFilter, IsRawDataIgnoredWhenFilteringFailed = _raygunSettings.IsRawDataIgnoredWhenFilteringFailed, UseKeyValuePairRawDataFilter = _raygunSettings.UseKeyValuePairRawDataFilter }; options.AddCookieNames(_raygunSettings.IgnoreCookieNames ?? Array.Empty <string>()); options.AddHeaderNames(_raygunSettings.IgnoreHeaderNames ?? Array.Empty <string>()); options.AddFormFieldNames(_raygunSettings.IgnoreFormFieldNames ?? Array.Empty <string>()); options.AddQueryParameterNames(_raygunSettings.IgnoreQueryParameterNames ?? Array.Empty <string>()); options.AddSensitiveFieldNames(_raygunSettings.IgnoreSensitiveFieldNames ?? Array.Empty <string>()); options.AddServerVariableNames(_raygunSettings.IgnoreServerVariableNames ?? Array.Empty <string>()); RaygunRequestMessage httpRequestMessage = RaygunAspNetCoreRequestMessageBuilder .Build(_httpContextAccessor.HttpContext, options) .GetAwaiter() .GetResult(); RaygunResponseMessage httpResponseMessage = RaygunAspNetCoreResponseMessageBuilder.Build(_httpContextAccessor.HttpContext); // The Raygun request/response messages are stored in the logEvent properties collection. // When the error is sent to Raygun, these messages are extracted from the known properties // and then removed so as to not duplicate data in the payload. logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty(RaygunRequestMessagePropertyName, httpRequestMessage, true)); logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty(RaygunResponseMessagePropertyName, httpResponseMessage, true)); }
private static RaygunResponseMessage BuildResponseMessageFromStructureValue(StructureValue responseMessageStructure) { var responseMessage = new RaygunResponseMessage(); foreach (var property in responseMessageStructure.Properties) { switch (property.Name) { case nameof(RaygunResponseMessage.Content): responseMessage.Content = property.AsString(); break; case nameof(RaygunResponseMessage.StatusCode): responseMessage.StatusCode = property.AsInteger(); break; case nameof(RaygunResponseMessage.StatusDescription): responseMessage.StatusDescription = property.AsString(); break; } } return(responseMessage); }
public RaygunAspNetCoreMessageBuilder SetResponseDetails(RaygunResponseMessage message) { _raygunMessage.Details.Response = message; return(this); }