|
| 1 | +// Copyright The OpenTelemetry Authors |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package opencensus // import "go.opentelemetry.io/otel/bridge/opencensus" |
| 16 | + |
| 17 | +import ( |
| 18 | + "context" |
| 19 | + "testing" |
| 20 | + |
| 21 | + "github.com/stretchr/testify/assert" |
| 22 | + "github.com/stretchr/testify/require" |
| 23 | + |
| 24 | + "go.opentelemetry.io/otel/sdk/trace" |
| 25 | + "go.opentelemetry.io/otel/sdk/trace/tracetest" |
| 26 | +) |
| 27 | + |
| 28 | +func TestNewTraceBridge(t *testing.T) { |
| 29 | + exporter := tracetest.NewInMemoryExporter() |
| 30 | + tp := trace.NewTracerProvider(trace.WithSyncer(exporter)) |
| 31 | + bridge := newTraceBridge([]TraceOption{WithTracerProvider(tp)}) |
| 32 | + _, span := bridge.StartSpan(context.Background(), "foo") |
| 33 | + span.End() |
| 34 | + gotSpans := exporter.GetSpans() |
| 35 | + require.Len(t, gotSpans, 1) |
| 36 | + gotSpan := gotSpans[0] |
| 37 | + assert.Equal(t, gotSpan.InstrumentationLibrary.Name, scopeName) |
| 38 | + assert.Equal(t, gotSpan.InstrumentationLibrary.Version, Version()) |
| 39 | +} |
0 commit comments