Example #1
0
        public void CaptureException(Exception exception, string culprit = null, bool isHandled = false)
        {
            var capturedCulprit = string.IsNullOrEmpty(culprit) ? "PublicAPI-CaptureException" : culprit;
            var error           = new Error.Err
            {
                Culprit   = capturedCulprit,
                Exception = new CapturedException
                {
                    Message = exception.Message,
                    Type    = exception.GetType().FullName,
                    Handled = isHandled
                },
                Transaction = new Error.Err.Trans
                {
                    Id = Id
                }
            };

            if (!string.IsNullOrEmpty(exception.StackTrace))
            {
                error.Exception.StacktTrace
                    = StacktraceHelper.GenerateApmStackTrace(new StackTrace(exception).GetFrames(), _logger,
                                                             "failed capturing stacktrace");
            }

            error.Context = Context;
            _sender.QueueError(new Error {
                Errors = new List <Error.Err> {
                    error
                }, Service = Service
            });
        }
Example #2
0
        public void CaptureError(string message, string culprit, StackFrame[] frames)
        {
            var error = new Error.Err
            {
                Culprit   = culprit,
                Exception = new CapturedException
                {
                    Message = message
                },
                Transaction = new Error.Err.Trans
                {
                    Id = Id
                }
            };

            if (frames != null)
            {
                error.Exception.StacktTrace
                    = StacktraceHelper.GenerateApmStackTrace(frames, _logger, "failed capturing stacktrace");
            }

            error.Context = Context;
            _sender.QueueError(new Error {
                Errors = new List <Error.Err> {
                    error
                }, Service = Service
            });
        }
        public void CaptureException(Exception exception, string culprit = null, bool isHandled = false)
        {
            var capturedCulprit = String.IsNullOrEmpty(culprit) ? "PublicAPI-CaptureException" : culprit;
            var error           = new Error.Err
            {
                Culprit   = capturedCulprit,
                Exception = new CapturedException
                {
                    Message = exception.Message,
                    Type    = exception.GetType().FullName,
                    Handled = isHandled
                },
                Transaction = new Error.Err.Trans
                {
                    Id = this.Id
                }
            };

            if (!String.IsNullOrEmpty(exception.StackTrace))
            {
                error.Exception.Stacktrace
                    = StacktraceHelper.GenerateApmStackTrace(new System.Diagnostics.StackTrace(exception).GetFrames(), Api.ElasticApm.PublicApiLogger, "failed capturing stacktrace");
            }

            error.Context = this.Context;
            Apm.Agent.PayloadSender.QueueError(new Error {
                Errors = new List <Error.Err> {
                    error
                }, Service = this.service
            });
        }