Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Opentelemetry issue#1699 #68

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
To prevent backwards incompatible changes when it is specified, these links are removed. (#1726)
- Setting error status while recording error with Span from oteltest package. (#1729)

### Fixed

- Fixes the typo `testCollectorEnpoint` to `testCollectorEndpoint` and added assertion on `gen.Batch` process. (#TBD)

## [0.19.0] - 2021-03-18

### Added
Expand Down
26 changes: 15 additions & 11 deletions exporters/trace/jaeger/jaeger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,24 +277,24 @@ func TestNewRawExporterShouldFailIfCollectorUnset(t *testing.T) {
assert.Error(t, err)
}

type testCollectorEnpoint struct {
type testCollectorEndpoint struct {
batchesUploaded []*gen.Batch
}

func (c *testCollectorEnpoint) upload(batch *gen.Batch) error {
func (c *testCollectorEndpoint) upload(batch *gen.Batch) error {
c.batchesUploaded = append(c.batchesUploaded, batch)
return nil
}

var _ batchUploader = (*testCollectorEnpoint)(nil)
var _ batchUploader = (*testCollectorEndpoint)(nil)

func withTestCollectorEndpoint() func() (batchUploader, error) {
return func() (batchUploader, error) {
return &testCollectorEnpoint{}, nil
return &testCollectorEndpoint{}, nil
}
}

func withTestCollectorEndpointInjected(ce *testCollectorEnpoint) func() (batchUploader, error) {
func withTestCollectorEndpointInjected(ce *testCollectorEndpoint) func() (batchUploader, error) {
return func() (batchUploader, error) {
return ce, nil
}
Expand All @@ -319,19 +319,23 @@ func TestExporter_ExportSpan(t *testing.T) {

assert.NoError(t, err)

tp := sdktrace.NewTracerProvider(
sdktrace.WithSampler(sdktrace.AlwaysSample()),
sdktrace.WithSyncer(exp),
)
opts := append(exp.o.TracerProviderOptions, sdktrace.WithSyncer(exp))
tp := sdktrace.NewTracerProvider(opts...)
Aneurysm9 marked this conversation as resolved.
Show resolved Hide resolved
otel.SetTracerProvider(tp)
_, span := otel.Tracer("test-tracer").Start(context.Background(), "test-span")
span.End()

assert.True(t, span.SpanContext().IsValid())

exp.Flush()
tc := exp.uploader.(*testCollectorEnpoint)
tc := exp.uploader.(*testCollectorEndpoint)
assert.True(t, len(tc.batchesUploaded) == 1)

assert.Equal(t, serviceName, tc.batchesUploaded[0].GetProcess().GetServiceName())
assert.Equal(t, 1, len(tc.batchesUploaded[0].GetProcess().GetTags()))
assert.Equal(t, tagKey, tc.batchesUploaded[0].GetProcess().GetTags()[0].GetKey())
assert.Equal(t, tagVal, tc.batchesUploaded[0].GetProcess().GetTags()[0].GetVStr())

assert.True(t, len(tc.batchesUploaded[0].GetSpans()) == 1)
}

Expand Down Expand Up @@ -905,7 +909,7 @@ func TestNewExporterPipelineWithOptions(t *testing.T) {
eventCountLimit = 10
)

testCollector := &testCollectorEnpoint{}
testCollector := &testCollectorEndpoint{}
tp, spanFlush, err := NewExportPipeline(
withTestCollectorEndpointInjected(testCollector),
WithSDKOptions(
Expand Down