go.undefinedlabs.com/scopeagent@v0.4.2/tracer/recorder_test.go (about) 1 package tracer 2 3 import ( 4 "sync/atomic" 5 "testing" 6 "time" 7 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestInMemoryRecorderSpans(t *testing.T) { 12 recorder := NewInMemoryRecorder() 13 var apiRecorder SpanRecorder = recorder 14 span := RawSpan{ 15 Context: SpanContext{}, 16 Operation: "test-span", 17 Start: time.Now(), 18 Duration: -1, 19 } 20 apiRecorder.RecordSpan(span) 21 assert.Equal(t, []RawSpan{span}, recorder.GetSpans()) 22 assert.Equal(t, []RawSpan{}, recorder.GetSampledSpans()) 23 } 24 25 type CountingRecorder int32 26 27 func (c *CountingRecorder) RecordSpan(r RawSpan) { 28 atomic.AddInt32((*int32)(c), 1) 29 }