首页 文章

这是Application Insight / Azure Functions Bug吗?或者我的理解不正确

提问于
浏览
0

今天,我将Azure功能与应用程序日志记录的应用程序洞察集成,特别是捕获错误堆栈跟踪 .

首先,我编写了Azure函数,没有try-catch块,因此它在Monitor部分和应用程序洞察中也显示了正确的状态/信息 .

后来我添加了try-catch块并记录了更多的数据

catch(Exception ex)
{
    log.Error(inputData);
    log.Error(ex.Message);
    return req.CreateResponse(HttpStatusCode.InternalServerError);
}

您可以在下面的附件中看到,ResultCode是500,绿色状态...为什么?我认为由于此问题,Application Insight未在错误/失败请求查询中显示此数据 .

enter image description here

在Application Insight中找不到记录

exceptions
|where operation_Id == "c5b5a345-fa11-4356-b769-b34d1c6619e5" 
| order by timestamp desc 
| project operation_Id , timestamp

enter image description here

1 回答

  • 1

    成功检查表示您的Azure函数调用是否成功(=没有抛出异常)或失败(=抛出异常) .

    在第一次调用时,发生了异常,因此函数调用没有正常终止,因此是红色复选标记 .

    当你手动捕获并返回500时,在函数调用方面仍然可以 - 它完成并返回结果 .

    函数运行时不遵循HTTP语义,规则对所有触发器类型都是通用的 .

    Application Insight默认度量标准不会在失败的请求图中显示已处理的异常,Developer需要对已处理的异常构建查询,例如

    requests
    | where success == "False" and timestamp >= ago(7d) 
    | join kind= inner traces on operation_Id  
    | project operation_Id , timestamp, message, severityLevel  
    | order  by timestamp, operation_Id
    
    severityLevel :- 1 = Info and 3 = Error
    

相关问题