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 29
|
package basictracer
import (
"sync/atomic"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestInMemoryRecorderSpans(t *testing.T) {
recorder := NewInMemoryRecorder()
var apiRecorder SpanRecorder = recorder
span := RawSpan{
Context: SpanContext{},
Operation: "test-span",
Start: time.Now(),
Duration: -1,
}
apiRecorder.RecordSpan(span)
assert.Equal(t, []RawSpan{span}, recorder.GetSpans())
assert.Equal(t, []RawSpan{}, recorder.GetSampledSpans())
}
type CountingRecorder int32
func (c *CountingRecorder) RecordSpan(r RawSpan) {
atomic.AddInt32((*int32)(c), 1)
}
|