Skip to content

Commit fbe3ac5

Browse files
fix(cozeloop): ensure span.Finish called on panic and handle []byte aliases in interrupt data
- Move span.Finish(ctx) into defer block in OnEnd goroutine to guarantee span is finished even if ParseOutput/SetTags panics - Use reflect to detect []byte-based types (e.g. json.RawMessage) in serializeInterruptInfo to avoid writing binary data into span tags Change-Id: Ie70d9fb1eb2593924affd8a939b492a592d8939e
1 parent 211c2d4 commit fbe3ac5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

callbacks/cozeloop/data_parser.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,8 @@ func serializeInterruptInfo(info *adk.InterruptInfo) map[string]any {
734734
result := make(map[string]any)
735735

736736
if info.Data != nil {
737-
if _, ok := info.Data.([]byte); !ok {
737+
rv := reflect.ValueOf(info.Data)
738+
if rv.Kind() != reflect.Slice || rv.Type().Elem().Kind() != reflect.Uint8 {
738739
result["data"] = info.Data
739740
}
740741
}

callbacks/cozeloop/trace_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ func (l *einoTracer) OnEnd(ctx context.Context, info *callbacks.RunInfo, output
134134
if e := recover(); e != nil {
135135
l.logger.CtxWarnf(ctx, "[einoTracer][OnEnd] recovered: %s", e)
136136
}
137+
span.Finish(ctx)
137138
}()
138139

139140
tags := l.parser.ParseOutput(ctx, info, output)
140141
span.SetTags(ctx, tags)
141-
span.Finish(ctx)
142142
}()
143143
} else {
144144
span.Finish(ctx)

0 commit comments

Comments
 (0)