diff --git a/span.go b/span.go index 4d4de2d..f5b3d8e 100644 --- a/span.go +++ b/span.go @@ -79,6 +79,8 @@ type Span interface { // // The keys must all be strings. The values may be strings, numeric types, // bools, Go error instances, or arbitrary structs. + // + // (Note to implementors: consider the log.InterleavedKVToFields() helper) LogKV(alternatingKeyValues ...interface{}) // SetBaggageItem sets a key:value pair on this Span and its SpanContext @@ -155,3 +157,14 @@ type LogData struct { Event string Payload interface{} } + +// ToLogRecord converts a deprecated LogData to a non-deprecated LogRecord +func (ld *LogData) ToLogRecord() LogRecord { + return LogRecord{ + Timestamp: ld.Timestamp, + Fields: []log.Field{ + log.String("event", ld.Event), + log.Object("payload", ld.Payload), + }, + } +}