add a timestamp to trace events (#34)

This commit is contained in:
Marten Seemann 2022-06-01 16:08:25 +02:00 committed by GitHub
parent 2e798e3cc5
commit 50387915ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,6 +47,7 @@ const (
)
type traceEvt struct {
Time string
Type string
Scope string `json:",omitempty"`
@ -70,13 +71,14 @@ type traceEvt struct {
FD int `json:",omitempty"`
}
func (t *trace) push(evt interface{}) {
func (t *trace) push(evt traceEvt) {
t.mx.Lock()
defer t.mx.Unlock()
if t.done {
return
}
evt.Time = time.Now().Format(time.RFC3339)
t.pend = append(t.pend, evt)
}