示例#1
0
        private RaygunRequestMessage BuildRequestMessage()
        {
            RaygunRequestMessage requestMessage = null;
            HttpContext          context        = HttpContext.Current;

            if (context != null)
            {
                HttpRequest request = null;
                try
                {
                    request = context.Request;
                }
                catch (HttpException ex)
                {
                    System.Diagnostics.Trace.WriteLine("Error retrieving HttpRequest {0}", ex.Message);
                }

                if (request != null)
                {
                    requestMessage = RaygunRequestMessageBuilder.Build(request, _requestMessageOptions);
                }
            }

            return(requestMessage);
        }
示例#2
0
        private RaygunRequestMessage BuildRequestMessage()
        {
            RaygunRequestMessage requestMessage = null;
            HttpContext          context        = HttpContext.Current;

            if (context != null)
            {
                HttpRequest request = null;
                try
                {
                    request = context.Request;
                }
                catch (HttpException ex)
                {
                    RaygunLogger.Instance.Error($"Failed to retrieve the HttpRequest due to: {ex.Message}");
                }

                if (request != null)
                {
                    requestMessage = RaygunRequestMessageBuilder.Build(request, _requestMessageOptions);
                }
            }

            return(requestMessage);
        }
示例#3
0
 /// <summary>
 /// Asynchronously transmits an exception to Raygun.io.
 /// </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 void SendInBackground(Exception exception, IList <string> tags, IDictionary userCustomData, RaygunIdentifierMessage userInfo)
 {
     if (CanSend(exception))
     {
         // We need to process the HttpRequestMessage on the current thread,
         // otherwise it will be disposed while we are using it on the other thread.
         RaygunRequestMessage currentRequestMessage = BuildRequestMessage();
         var currentTime = DateTime.UtcNow;
         ThreadPool.QueueUserWorkItem(c =>
         {
             try
             {
                 _currentRequestMessage = currentRequestMessage;
                 StripAndSend(exception, tags, userCustomData, userInfo, currentTime);
             }
             catch (Exception)
             {
                 // This will swallow any unhandled exceptions unless we explicitly want to throw on error.
                 // Otherwise this can bring the whole process down.
                 if (RaygunSettings.Settings.ThrowOnError)
                 {
                     throw;
                 }
             }
         });
         FlagAsSent(exception);
     }
 }
示例#4
0
        /// <summary>
        /// Transmits an exception to Raygun.io synchronously specifying a list of string tags associated
        /// with the message for identification, as well as sending a key-value collection of custom data.
        /// This uses the version number of the originating assembly.
        /// </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 void Send(Exception exception, IList <string> tags, IDictionary userCustomData, RaygunIdentifierMessage userInfo)
        {
            if (CanSend(exception))
            {
                _currentRequestMessage = BuildRequestMessage();

                StripAndSend(exception, tags, userCustomData, userInfo, null);
                FlagAsSent(exception);
            }
        }
        /// <summary>
        /// Transmits an exception to Raygun.io synchronously specifying a list of string tags associated
        /// with the message for identification, as well as sending a key-value collection of custom data.
        /// This uses the version number of the originating assembly.
        /// </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>
        public void Send(Exception exception, IList <string> tags, IDictionary userCustomData)
        {
            if (CanSend(exception))
            {
                _currentRequestMessage = BuildRequestMessage();

                Send(BuildMessage(exception, tags, userCustomData));
                FlagAsSent(exception);
            }
        }
示例#6
0
        /// <summary>
        /// Asynchronously transmits an exception to Raygun.io.
        /// </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>
        public void SendInBackground(Exception exception, IList <string> tags, IDictionary userCustomData)
        {
            // We need to process the HttpRequestMessage on the current thread,
            // otherwise it will be disposed while we are using it on the other thread.
            RaygunRequestMessage currentRequestMessage = BuildRequestMessage();

            ThreadPool.QueueUserWorkItem(c => {
                _currentRequestMessage = currentRequestMessage;
                Send(BuildMessage(exception, tags, userCustomData));
            });
        }
        public override void SendInBackground(System.Exception exception, System.Collections.Generic.IList <string> tags, System.Collections.IDictionary userCustomData)
        {
            if (CanSend(exception))
            {
                // We need to process the HttpRequestMessage on the current thread,
                // otherwise it will be disposed while we are using it on the other thread.
                RaygunRequestMessage currentRequestMessage = BuildRequestMessage();

                ThreadPool.QueueUserWorkItem(c =>
                {
                    _currentRequestMessage.Value = currentRequestMessage;
                    Send(BuildMessage(exception, tags, userCustomData));
                    _currentRequestMessage.Value = null;
                });
                FlagAsSent(exception);
            }
        }
示例#8
0
        /// <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>
        public async Task SendInBackground(Exception exception, IList <string> tags, IDictionary userCustomData)
        {
            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);
                });
                FlagAsSent(exception);
                await task;
            }
        }
        private RaygunRequestMessage BuildRequestMessage()
        {
            RaygunRequestMessage requestMessage = null;
            HttpContext          context        = HttpContext.Current;

            if (context != null)
            {
                HttpRequest request = null;
                try
                {
                    request = context.Request;
                }
                catch (HttpException) { }

                if (request != null)
                {
                    requestMessage = new RaygunRequestMessage(request, _requestMessageOptions ?? new RaygunRequestMessageOptions());
                }
            }

            return(requestMessage);
        }
示例#10
0
 public IRaygunMessageBuilder SetHttpDetails(RaygunRequestMessage message)
 {
     _raygunMessage.Details.Request = message;
     return(this);
 }
示例#11
0
        /// <summary>
        /// Transmits an exception to Raygun.io synchronously specifying a list of string tags associated
        /// with the message for identification, as well as sending a key-value collection of custom data.
        /// </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>
        public void Send(Exception exception, IList <string> tags, IDictionary userCustomData)
        {
            _currentRequestMessage = BuildRequestMessage();

            Send(BuildMessage(exception, tags, userCustomData, null));
        }