这是Application Insight/Azure功能错误吗?或我的理解不正确 [英] Is this Application Insight / Azure Functions Bug? or My understanding is incorrect

查看:73
本文介绍了这是Application Insight/Azure功能错误吗?或我的理解不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我将Azure功能与应用程序见解集成在一起,以进行应用程序日志记录,尤其是捕获错误堆栈跟踪.

Today I integrate my Azure function with Application insight for application logging, especially to capture error stack-trace.

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

First I have written Azure function without try-catch block so It was showing correct status/Information in Monitor section and application insight as well.

稍后,我添加了try-catch块并记录了更多数据,例如

Later I added try-catch block and logged some more data like

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

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

You can see in below attachment, ResultCode is 500 with Green Status... Why? I think because of this issue Application Insight not showing this data in Error/Failed request query.

在Application Insight中找不到记录

No record found in Application Insight

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

推荐答案

成功检查表示您的Azure Function调用是成功(=未引发异常)还是失败(=引发异常).

Success check denotes whether your Azure Function call succeeded (= no exception thrown) or failed (= exception thrown).

第一次调用时发生异常,因此函数调用未正常终止,因此出现红色选中标记.

At your first invocation, an exception occurred, so function invocation didn't terminate normally, thus red checkmark.

当您手动捕获并返回500时,就函数调用而言还是可以的-它完成并返回结果.

When you catch and return 500 manually, that's still OK in terms of function invocation - it finished and returned the result back.

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

Functions runtime doesn't follow HTTP semantics, the rules are universal for all trigger types.

Application Insight默认指标不会在失败的请求图中显示已处理的异常,开发人员需要针对已处理的异常进行构建查询,例如

Application Insight Default metrics won't show handled exception in failed request graph, Developer need build query for handled exception e.g.

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

这篇关于这是Application Insight/Azure功能错误吗?或我的理解不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆