Share source evidence through the selected capture sink

This commit is contained in:
2026-11-26 01:55:37 +00:00
parent f49238c787
commit 6133902b9b
15 changed files with 286 additions and 44 deletions

View File

@@ -20,6 +20,12 @@ type DebugRecorder interface {
type noopDebugRecorder struct{}
// evidenceDebugRecorder adapts the selected caller-owned evidence sink without
// adding synchronization; explicit writers own their concurrent-call safety.
type evidenceDebugRecorder struct{ contracts.EvidenceWriter }
func (evidenceDebugRecorder) Enabled() bool { return true }
func NoopDebugRecorder() DebugRecorder { return noopDebugRecorder{} }
func (noopDebugRecorder) Enabled() bool { return false }
@@ -110,7 +116,10 @@ func writeDebugTimed(recorder DebugRecorder, name string, envelope debugTimedEnv
if envelope.DurationMS == 0 {
envelope.DurationMS = envelope.CompletedAt.Sub(envelope.StartedAt).Milliseconds()
}
return recorder.WriteJSON(name, envelope)
if err := recorder.WriteJSON(name, envelope); err != nil {
return &contracts.CaptureError{Cause: err}
}
return nil
}
func debugContentEnvelope(content []byte, mediaType string, metadata map[string]any, _ any) debugBinaryEnvelope {