Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Commit

Permalink
event: update NetTraceIntegrator to support LogFields, Tag
Browse files Browse the repository at this point in the history
NetTraceIntegrator now handles EventLogFields and EventTag and produces
messages for them.
  • Loading branch information
RaduBerinde committed Sep 28, 2016
1 parent 1fd08ce commit 6cabe56
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion events/event_nettrace.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package events

import (
"github.com/opentracing/basictracer-go"
"bytes"
"fmt"

"golang.org/x/net/trace"

basictracer "github.com/opentracing/basictracer-go"
)

// NetTraceIntegrator can be passed into a basictracer as NewSpanEventListener
Expand All @@ -16,6 +20,18 @@ var NetTraceIntegrator = func() func(basictracer.SpanEvent) {
tr.SetMaxEvents(1000)
case basictracer.EventFinish:
tr.Finish()
case basictracer.EventTag:
tr.LazyPrintf("%s:%v", t.Key, t.Value)
case basictracer.EventLogFields:
var buf bytes.Buffer
for i, f := range t.Fields {
if i > 0 {
buf.WriteByte(' ')
}
fmt.Fprintf(&buf, "%s:%v", f.Key(), f.Value())
}

tr.LazyPrintf("%s", buf.String())
case basictracer.EventLog:
if t.Payload != nil {
tr.LazyPrintf("%s (payload %v)", t.Event, t.Payload)
Expand Down

0 comments on commit 6cabe56

Please sign in to comment.