add sampler in test
This commit is contained in:
@@ -30,10 +30,6 @@ import (
|
|||||||
semconv "go.opentelemetry.io/otel/semconv/v1.10.0"
|
semconv "go.opentelemetry.io/otel/semconv/v1.10.0"
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
"gotest.tools/assert/cmp"
|
"gotest.tools/assert/cmp"
|
||||||
//"github.com/virtual-kubelet/virtual-kubelet/trace"
|
|
||||||
//octrace "go.opencensus.io/trace"
|
|
||||||
//"gotest.tools/assert"
|
|
||||||
//is "gotest.tools/assert/cmp"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStartSpan(t *testing.T) {
|
func TestStartSpan(t *testing.T) {
|
||||||
@@ -93,7 +89,6 @@ func TestSetStatus(t *testing.T) {
|
|||||||
assert.Assert(t, !s.s.IsRecording())
|
assert.Assert(t, !s.s.IsRecording())
|
||||||
assert.Assert(t, e.status.Code == tt.expectedCode)
|
assert.Assert(t, e.status.Code == tt.expectedCode)
|
||||||
assert.Assert(t, e.status.Description == tt.expectedDescription)
|
assert.Assert(t, e.status.Description == tt.expectedDescription)
|
||||||
|
|
||||||
s.SetStatus(tt.inputStatus) // should not be panic even if span is ended.
|
s.SetStatus(tt.inputStatus) // should not be panic even if span is ended.
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -147,9 +142,8 @@ func TestWithField(t *testing.T) {
|
|||||||
s.End()
|
s.End()
|
||||||
|
|
||||||
assert.Assert(t, len(e.attributes) == len(tt.expectedAttributes))
|
assert.Assert(t, len(e.attributes) == len(tt.expectedAttributes))
|
||||||
for i, a := range tt.expectedAttributes {
|
for _, a := range tt.expectedAttributes {
|
||||||
assert.Assert(t, e.attributes[i].Key == a.Key)
|
cmp.Contains(e.attributes, a)
|
||||||
assert.Assert(t, e.attributes[i].Value == a.Value)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -191,9 +185,8 @@ func TestWithFields(t *testing.T) {
|
|||||||
s.End()
|
s.End()
|
||||||
|
|
||||||
assert.Assert(t, len(e.attributes) == len(tt.expectedAttributes))
|
assert.Assert(t, len(e.attributes) == len(tt.expectedAttributes))
|
||||||
for i, a := range tt.expectedAttributes {
|
for _, a := range tt.expectedAttributes {
|
||||||
assert.Assert(t, e.attributes[i].Key == a.Key)
|
cmp.Contains(e.attributes, a)
|
||||||
assert.Assert(t, e.attributes[i].Value == a.Value)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -272,9 +265,8 @@ func TestLog(t *testing.T) {
|
|||||||
|
|
||||||
//TODO add assertion with exporter here once logic for recoding log event is added.
|
//TODO add assertion with exporter here once logic for recoding log event is added.
|
||||||
assert.Assert(t, len(l.a) == len(tt.expectedAttributes))
|
assert.Assert(t, len(l.a) == len(tt.expectedAttributes))
|
||||||
for i, a := range tt.expectedAttributes {
|
for _, a := range tt.expectedAttributes {
|
||||||
assert.Assert(t, l.a[i].Key == a.Key)
|
cmp.Contains(l.a, a)
|
||||||
assert.Assert(t, l.a[i].Value == a.Value)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -519,6 +511,7 @@ func setupSuite() (func(provider *sdktrace.TracerProvider), *sdktrace.TracerProv
|
|||||||
p := sdktrace.NewTracerProvider(
|
p := sdktrace.NewTracerProvider(
|
||||||
sdktrace.WithSyncer(e),
|
sdktrace.WithSyncer(e),
|
||||||
sdktrace.WithResource(r),
|
sdktrace.WithResource(r),
|
||||||
|
sdktrace.WithSampler(sdktrace.AlwaysSample()),
|
||||||
)
|
)
|
||||||
otel.SetTracerProvider(p)
|
otel.SetTracerProvider(p)
|
||||||
|
|
||||||
@@ -538,6 +531,7 @@ func NewResource(name, version string) *resource.Resource {
|
|||||||
|
|
||||||
type fakeExporter struct {
|
type fakeExporter struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
// attributes describe the aspects of the spans.
|
||||||
attributes []attribute.KeyValue
|
attributes []attribute.KeyValue
|
||||||
// Links returns all the links the span has to other spans.
|
// Links returns all the links the span has to other spans.
|
||||||
links []sdktrace.Link
|
links []sdktrace.Link
|
||||||
|
|||||||
Reference in New Issue
Block a user