应用程序洞察持续时间指标

Application insights durations metrics

我有一个 Azure Function App。我想记录该函数应用程序中某些特定代码部分的持续时间。将其存储在何处才是合适的地方?我可以看到 dependencies 是唯一具有持续时间 属性 的集合。但是文档指出这个集合主要是 SQL 服务器、存储等。页面浏览量和请求也有这个,但似乎不是正确的地方。您添加这种监控的任何指示?

您可以将它们记录为 customMetrics

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

        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 portal -> application insights -> logs中,可以在customMetrics中查看持续时间 table: