File: opencensus_test.go

package info (click to toggle)
golang-github-go-kit-kit 0.13.0-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,784 kB
  • sloc: sh: 22; makefile: 11
file content (28 lines) | stat: -rw-r--r-- 411 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
}