Codebase list golang-github-go-kit-kit / run/dff50435-7a33-4f0c-bbdc-f455eb10d80a/main tracing / opencensus / opencensus_test.go
run/dff50435-7a33-4f0c-bbdc-f455eb10d80a/main

Tree @run/dff50435-7a33-4f0c-bbdc-f455eb10d80a/main (Download .tar.gz)

opencensus_test.go @run/dff50435-7a33-4f0c-bbdc-f455eb10d80a/mainraw · history · blame

package opencensus_test

import (
	"sync"

	"go.opencensus.io/trace"
)

type recordingExporter struct {
	mu   sync.Mutex
	data []*trace.SpanData
}

func (e *recordingExporter) ExportSpan(d *trace.SpanData) {
	e.mu.Lock()
	defer e.mu.Unlock()

	e.data = append(e.data, d)
}

func (e *recordingExporter) Flush() (data []*trace.SpanData) {
	e.mu.Lock()
	defer e.mu.Unlock()

	data = e.data
	e.data = nil
	return
}