Codebase list golang-github-go-kit-kit / d2f2902b-79c4-43cd-8c09-341e33fc6017/upstream/0.12.0+git20220826.1.a7ba4fa tracing / opencensus / opencensus_test.go
d2f2902b-79c4-43cd-8c09-341e33fc6017/upstream/0.12.0+git20220826.1.a7ba4fa

Tree @d2f2902b-79c4-43cd-8c09-341e33fc6017/upstream/0.12.0+git20220826.1.a7ba4fa (Download .tar.gz)

opencensus_test.go @d2f2902b-79c4-43cd-8c09-341e33fc6017/upstream/0.12.0+git20220826.1.a7ba4faraw · 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
}