mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-09-15 17:35:00 +00:00
fix: 修复链路追踪输出记录及关闭追踪时的额外开销
This commit is contained in:
@@ -43,26 +43,26 @@ public class DefaultTraceStreamSpan implements TraceStreamSpan {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishSuccess() {
|
||||
finish(TraceConstants.STATUS_SUCCESS, null);
|
||||
public void finishSuccess(String outputPayload) {
|
||||
finish(TraceConstants.STATUS_SUCCESS, null, outputPayload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishError(Throwable throwable) {
|
||||
finish(TraceConstants.STATUS_ERROR, TracePayloadUtils.error(throwable, traceProperties));
|
||||
finish(TraceConstants.STATUS_ERROR, TracePayloadUtils.error(throwable, traceProperties), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishCancelledIfRunning() {
|
||||
finish(TraceConstants.STATUS_CANCELLED, null);
|
||||
finish(TraceConstants.STATUS_CANCELLED, null, null);
|
||||
}
|
||||
|
||||
private void finish(String status, String errorMessage) {
|
||||
private void finish(String status, String errorMessage, String outputPayload) {
|
||||
if (!finished.compareAndSet(false, true)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
traceRecordService.finishNode(traceId, nodeId, status, errorMessage, null,
|
||||
traceRecordService.finishNode(traceId, nodeId, status, errorMessage, outputPayload,
|
||||
new Date(), System.currentTimeMillis() - startMillis);
|
||||
} catch (Exception e) {
|
||||
log.warn("结束 trace stream span 失败,traceId={}, nodeId={}", traceId, nodeId, e);
|
||||
|
||||
@@ -7,7 +7,14 @@ public interface TraceStreamSpan {
|
||||
|
||||
void detach();
|
||||
|
||||
void finishSuccess();
|
||||
/**
|
||||
* 结束成功的流式节点,并可写入输出摘要。
|
||||
*/
|
||||
default void finishSuccess() {
|
||||
finishSuccess(null);
|
||||
}
|
||||
|
||||
void finishSuccess(String outputPayload);
|
||||
|
||||
void finishError(Throwable throwable);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user