Commit 0aa629c7 authored by vyzo's avatar vyzo

use *pb.TraceEvent as argument for Trace in the EventTracer interface

parent f134d658
......@@ -11,7 +11,7 @@ import (
// Generic event tracer interface
type EventTracer interface {
Trace(evt interface{})
Trace(evt *pb.TraceEvent)
}
// pubsub tracer details
......
......@@ -14,10 +14,10 @@ import (
type basicTracer struct {
ch chan struct{}
mx sync.Mutex
buf []interface{}
buf []*pb.TraceEvent
}
func (t *basicTracer) Trace(evt interface{}) {
func (t *basicTracer) Trace(evt *pb.TraceEvent) {
t.mx.Lock()
t.buf = append(t.buf, evt)
t.mx.Unlock()
......@@ -57,7 +57,7 @@ func OpenJSONTracer(file string, flags int, perm os.FileMode) (*JSONTracer, erro
}
func (t *JSONTracer) doWrite() {
var buf []interface{}
var buf []*pb.TraceEvent
enc := json.NewEncoder(t.w)
for {
_, ok := <-t.ch
......@@ -109,7 +109,7 @@ func OpenPBTracer(file string, flags int, perm os.FileMode) (*PBTracer, error) {
}
func (t *PBTracer) doWrite() {
var buf []interface{}
var buf []*pb.TraceEvent
w := ggio.NewDelimitedWriter(t.w)
for {
_, ok := <-t.ch
......@@ -121,7 +121,7 @@ func (t *PBTracer) doWrite() {
t.mx.Unlock()
for i, evt := range buf {
err := w.WriteMsg(evt.(*pb.TraceEvent))
err := w.WriteMsg(evt)
if err != nil {
log.Errorf("error writing event trace: %s", err.Error())
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment