Skip to content

Commit 409e43f

Browse files
committed
支持不输出带有 nolog event 的 span
1 parent 7ba539b commit 409e43f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cmd/lcode-hub/otel-exporter.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ func (log ConsoleLogExporter) shouldLog(span sdktrace.ReadOnlySpan) bool {
126126
}
127127
if _, onStart := span.(sdktrace.ReadWriteSpan); !onStart { // onEnd
128128
for _, ev := range span.Events() {
129-
if ev.Name == err0.TheLogHasBeenOutput {
129+
switch ev.Name {
130+
case err0.TheLogHasBeenOutput:
131+
return false
132+
case "nolog":
130133
return false
131134
}
132135
}
@@ -189,8 +192,8 @@ func (log ConsoleLogExporter) PrintlnSpan(span sdktrace.ReadOnlySpan) (err error
189192
if onEnd := !onStart; onEnd {
190193
endStr = " end\n"
191194
}
195+
info += endStr
192196

193197
To1(io.WriteString(output, info))
194-
To1(io.WriteString(output, endStr))
195198
return
196199
}

0 commit comments

Comments
 (0)