functions
latest
false
函数用户指南
- 概述
- Python 函数
- 部署并运行
@traced 修饰符使单个执行步骤在作业追踪和 Maestro 仪表板中可见。使用它来批注执行有意义的工作的帮助程序函数,以便您可以查看时间花费在哪些位置以及运行失败。
from uipath.tracing import traced
@traced(name="fetch_document", run_type="uipath")
def fetch_document(document_id: str) -> bytes:
# implementation
...
def main(input: Input) -> Output: # do not trace the entry point
content = fetch_document(input.document_id)
return Output(result_id="123")
from uipath.tracing import traced
@traced(name="fetch_document", run_type="uipath")
def fetch_document(document_id: str) -> bytes:
# implementation
...
def main(input: Input) -> Output: # do not trace the entry point
content = fetch_document(input.document_id)
return Output(result_id="123")
重要提示:
请勿将 @traced 应用于入口点函数。运行时已将整个作业包含在自己的跨度中;追踪入口点会生成重复的嵌套跨度。
捕获的内容
每个追踪的步骤都记录其名称、运行类型、开始和结束时间以及状态。追踪记录已链接到 Orchestrator 作业,因此您可以从 Maestro 流程实例导航到运行的单个功能步骤。
指南
- 追踪表示不同工作单元的步骤 - 外部调用、提取、转换。
- 在每个步骤中使用清晰稳定的
name,以便在运行期间轻松读取追踪记录。 - 保留平台步骤的
run_type="uipath"。
后续步骤
- 调用函数— 查看 Maestro 流程的追踪记录。