end(event)


  • 名称:tracing:${name}:end

end 事件表示函数调用返回值的时刻。对于异步函数来说,这是指返回的 Promise 被解析的时候,而不是函数内部执行 return 语句的时候。此时,如果被跟踪的函数是同步的,result 字段将被设置为函数的返回值。或者,error 字段可能存在,用于表示任何抛出的错误。

【The end event represents the point at which a function call returns a value. In the case of an async function this is when the promise returned not when the function itself makes a return statement internally. At this point, if the traced function was synchronous the result field will be set to the return value of the function. Alternatively, the error field may be present to represent any thrown errors.】

建议专门监听 error 事件来跟踪错误,因为一个可追踪的操作可能会产生多个错误。例如,一个异步任务失败时,可能在任务的同步部分之前已在内部启动,然后抛出错误。

【It is recommended to listen specifically to the error event to track errors as it may be possible for a traceable action to produce multiple errors. For example, an async task which fails may be started internally before the sync part of the task then throws an error.】