go.undefinedlabs.com/scopeagent@v0.4.2/instrumentation/logging/recorder.go (about) 1 package logging 2 3 import "github.com/opentracing/opentracing-go" 4 5 type logRecorder interface { 6 Reset() 7 GetRecords() []opentracing.LogRecord 8 } 9 10 var recorders []logRecorder 11 12 // 13 // We are doing like this because there is no way to call span.LogFields with a custom timestamp on each event. 14 // The only way is to create an opentracing.LogRecord array and call later: 15 // span.FinishWithOptions(opentracing.FinishOptions{ 16 // LogRecords: logRecords, 17 // } 18 // 19 20 // Start record in all registered writers (used by the StartTest in order to generate new records for the span) 21 func Reset() { 22 for _, writer := range recorders { 23 writer.Reset() 24 } 25 } 26 27 // Stop record all registered writers (used by End in order to retrieve the records from the log and insert them in the span) 28 func GetRecords() []opentracing.LogRecord { 29 var records []opentracing.LogRecord 30 for _, writer := range recorders { 31 records = append(records, writer.GetRecords()...) 32 } 33 return records 34 }