internal static bool Capture(Exception e, ITransaction transaction, HttpContext httpContext, IConfigurationReader configurationReader, IApmLogger logger)
        {
            transaction.CaptureException(e);

            if (httpContext != null && configurationReader.ShouldExtractRequestBodyOnError())
            {
                transaction.CollectRequestInfo(httpContext, configurationReader, logger);
            }

            return(false);
        }
Example #2
0
		public void OnNext(KeyValuePair<string, object> kv)
		{
			if (kv.Key != "Microsoft.AspNetCore.Diagnostics.UnhandledException"
				&& kv.Key != "Microsoft.AspNetCore.Diagnostics.HandledException") return;

			var exception = kv.Value.GetType().GetTypeInfo().GetDeclaredProperty("exception").GetValue(kv.Value) as Exception;

			var transaction = _agent.Tracer.CurrentTransaction;

			transaction?.CaptureException(exception, "ASP.NET Core Unhandled Exception",
				kv.Key == "Microsoft.AspNetCore.Diagnostics.HandledException");

			var httpContext = kv.Value.GetType().GetTypeInfo().GetDeclaredProperty("httpContext").GetValue(kv.Value) as HttpContext;

			if (_confgurationReader.ShouldExtractRequestBodyOnError()) transaction.CollectRequestInfo(httpContext, _confgurationReader, _logger);
		}