应用洞察持续时间指标

时间:2020-04-11 16:18:57

标签: azure-application-insights azure-log-analytics

我有一个Azure Function应用。我想记录该功能应用程序中代码某些特定部分的持续时间。存放此物品的正确位置在哪里?我可以看到依赖项是唯一具有duration属性的集合。但是文档指出此集合主要是SQL Server,Storage等。页面视图和请求也具有此功能,但似乎不合适。在其中添加了此类监视的任何指针?

1 个答案:

答案 0 :(得分:0)

您可以将它们记录为customMetrics

LogMetric上使用ILogger instance扩展方法来创建自定义指标。

        public static void Run([BlobTrigger("samples-workitems/{name}", Connection = "AzureWebJobsStorage")]Stream myBlob, string name, ILogger log)
        {
            log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");

            //specify the name of the metric as the first parameter, and fill in the duration time as the 2nd parameter.
            log.LogMetric("duration_time", 119);
        }

然后在azure门户->应用程序见解->日志中,您可以在customMetrics表中检查持续时间:

enter image description here