Skip to content

Commit

Permalink
remove unused SpanRecorder from grpc interceptor test (#2312)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed May 26, 2022
1 parent 01864f4 commit e1b7ba8
Showing 1 changed file with 0 additions and 55 deletions.
Expand Up @@ -19,7 +19,6 @@ import (
"errors"
"io"
"strings"
"sync"
"testing"
"time"

Expand All @@ -42,60 +41,6 @@ import (
"google.golang.org/grpc/status"
)

type SpanRecorder struct {
startedMu sync.RWMutex
started []trace.ReadWriteSpan

endedMu sync.RWMutex
ended []trace.ReadOnlySpan
}

func NewSpanRecorder() *SpanRecorder {
return new(SpanRecorder)
}

// OnStart records started spans.
func (sr *SpanRecorder) OnStart(_ context.Context, s trace.ReadWriteSpan) {
sr.startedMu.Lock()
defer sr.startedMu.Unlock()
sr.started = append(sr.started, s)
}

// OnEnd records completed spans.
func (sr *SpanRecorder) OnEnd(s trace.ReadOnlySpan) {
sr.endedMu.Lock()
defer sr.endedMu.Unlock()
sr.ended = append(sr.ended, s)
}

// Shutdown does nothing.
func (sr *SpanRecorder) Shutdown(context.Context) error {
return nil
}

// ForceFlush does nothing.
func (sr *SpanRecorder) ForceFlush(context.Context) error {
return nil
}

// Started returns a copy of all started spans that have been recorded.
func (sr *SpanRecorder) Started() []trace.ReadWriteSpan {
sr.startedMu.RLock()
defer sr.startedMu.RUnlock()
dst := make([]trace.ReadWriteSpan, len(sr.started))
copy(dst, sr.started)
return dst
}

// Ended returns a copy of all ended spans that have been recorded.
func (sr *SpanRecorder) Ended() []trace.ReadOnlySpan {
sr.endedMu.RLock()
defer sr.endedMu.RUnlock()
dst := make([]trace.ReadOnlySpan, len(sr.ended))
copy(dst, sr.ended)
return dst
}

func getSpanFromRecorder(sr *tracetest.SpanRecorder, name string) (trace.ReadOnlySpan, bool) {
for _, s := range sr.Ended() {
if s.Name() == name {
Expand Down

0 comments on commit e1b7ba8

Please sign in to comment.