You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Azure门户查看Durable Functions的各类时间指标

在Azure门户的Application Insights中查看Durable Functions性能数据

1. 进入目标Application Insights资源

  • 打开Azure门户,找到你的Durable Functions对应的Application Insights资源(若为函数应用自动创建,名称通常和函数应用一致,后缀带-ai)
  • 进入资源后,左侧导航栏可选择性能或日志两种路径查看数据

2. 用内置性能面板快速查看响应时间

  • 在性能面板顶部的筛选器中,先选择云角色实例为你的函数应用,再在操作名称里筛选包含DurableActivity或DurableOrchestrator的操作(活动函数的操作名格式一般是DurableActivity.<你的活动函数名>,编排函数为DurableOrchestrator.<你的编排函数名>)
  • 面板会展示这些操作的平均响应时间、p95/p99百分位响应时间、调用次数等数据。但如果要拆分数据传输耗时和活动函数自身执行时间,内置面板的粒度不够,需要用日志自定义查询。

3. 用Kusto查询精准统计细分耗时

进入日志面板,输入以下Kusto查询来分别统计:

统计活动函数总响应时间(含传输)

requests
| where operation_Name startswith "DurableActivity"
| summarize 
    平均响应时间=avg(duration),
    p95响应时间=percentile(duration,95),
    总调用次数=count()
    by operation_Name
| sort by 平均响应时间 desc

拆分数据传输耗时与活动函数执行时间

Durable Functions会生成FunctionStarted/FunctionCompleted(记录函数执行周期)和Sending task response/Received task response(记录编排器与活动间的传输事件)两类关键日志,通过以下查询可拆分耗时:

// 获取函数启动/完成事件
let functionEvents = traces
| where customDimensions.Category == "Host.Aggregator"
| where message startswith "Function completed (" or message startswith "Function started ("
| parse message with * "Function " funcType " '" funcName "' (" instanceId ")" *
| extend eventType = iif(message startswith "Function completed", "Completed", "Started")
| project timestamp, funcName, instanceId, eventType;

// 获取传输事件
let transferEvents = traces
| where customDimensions.Category == "DurableTask.Core"
| where message contains "Sending task response" or message contains "Received task response"
| parse message with * "[" instanceId "]" *
| extend transferEventType = iif(message contains "Sending", "SendResponse", "ReceiveResponse")
| project timestamp, instanceId, transferEventType;

// 关联事件计算耗时
functionEvents
| join kind=inner transferEvents on instanceId
| summarize 
    函数执行耗时=datetime_diff('millisecond', max(timestamp), min(timestamp)),
    传输耗时=sum(iff(transferEventType in ("SendResponse", "ReceiveResponse"), datetime_diff('millisecond', max(timestamp), min(timestamp)), 0))
    by funcName, instanceId
| summarize 
    平均执行耗时=avg(函数执行耗时),
    平均传输耗时=avg(传输耗时)
    by funcName

关键字段说明

  • requests表的duration:从请求触发到响应返回的总耗时,包含数据传输和函数执行
  • traces表的DurableTask.Core类日志:记录编排器与活动函数之间的消息传输节点,用于计算传输耗时
  • FunctionStarted与FunctionCompleted的时间差:活动函数自身的执行耗时

注:由于无法直接提供截图,可参考以下界面描述:

  • 性能面板:筛选后会展示响应时间趋势折线图,下方表格列出各操作的性能明细
  • 日志面板:运行查询后返回统计表格,可通过顶部的可视化按钮将数据转为柱状图/折线图查看

内容的提问来源于stack exchange,提问作者TY00

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 21:30:15