mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-14 10:13:10 +02:00
422188a85f
* Update trace export interface Move to conforming to the specification. * Update documentation in export trace * Update sdk trace provider to support new trace exporter * Update SpanProcessors Support the Provider changes and new trace exporter. * Update the SDK to support the changes * Update trace Provider to not return an error * Update sdk with new Provider return Also fix the testExporter ExportSpans method * Update exporters with changes * Update examples with changes * Update Changelog * Move error handling to end of shutdown * Update exporter interface Rename to SpanExporter to match specification. Add an error return value to the Shutdown method based on feedback. Propagate these changes. Remove the Stop method from the OTLP exporter to avoid confusion and redundancy. * Add test to check OTLP Shutdown honors context * Add Jaeger exporter test for shutdown * Fix race in Jaeger test * Unify shutdown behavior and testing * Update sdk/trace/simple_span_processor.go Co-authored-by: Anthony Mirabella <a9@aneurysm9.com> Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
// Copyright The OpenTelemetry Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package tracetest
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"go.opentelemetry.io/otel/sdk/export/trace"
|
|
)
|
|
|
|
// TestNoop tests only that the no-op does not crash in different scenarios.
|
|
func TestNoop(t *testing.T) {
|
|
nsb := NewNoopExporter()
|
|
|
|
require.NoError(t, nsb.ExportSpans(context.Background(), nil))
|
|
require.NoError(t, nsb.ExportSpans(context.Background(), make([]*trace.SpanData, 10)))
|
|
require.NoError(t, nsb.ExportSpans(context.Background(), make([]*trace.SpanData, 0, 10)))
|
|
}
|
|
|
|
func TestNewInMemoryExporter(t *testing.T) {
|
|
imsb := NewInMemoryExporter()
|
|
|
|
require.NoError(t, imsb.ExportSpans(context.Background(), nil))
|
|
assert.Len(t, imsb.GetSpans(), 0)
|
|
|
|
input := make([]*trace.SpanData, 10)
|
|
for i := 0; i < 10; i++ {
|
|
input[i] = new(trace.SpanData)
|
|
}
|
|
require.NoError(t, imsb.ExportSpans(context.Background(), input))
|
|
sds := imsb.GetSpans()
|
|
assert.Len(t, sds, 10)
|
|
for i, sd := range sds {
|
|
assert.Same(t, input[i], sd)
|
|
}
|
|
imsb.Reset()
|
|
// Ensure that operations on the internal storage does not change the previously returned value.
|
|
assert.Len(t, sds, 10)
|
|
assert.Len(t, imsb.GetSpans(), 0)
|
|
|
|
require.NoError(t, imsb.ExportSpans(context.Background(), input[0:1]))
|
|
sds = imsb.GetSpans()
|
|
assert.Len(t, sds, 1)
|
|
assert.Same(t, input[0], sds[0])
|
|
}
|