1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-29 23:07:45 +02:00

Rename *Provider names (#1190)

* Rename *Provider names

There is overlap in naming with MeterProviders and TracerProviders. This
is means the specification is not implemented and these types can not
exist in the same package (#1179). This makes each type and related
functions and types explicit.

* Add changes to CHANGELOG
This commit is contained in:
Tyler Yahn
2020-09-23 15:16:13 -07:00
committed by GitHub
parent 5dd2962202
commit 7d71867644
49 changed files with 276 additions and 256 deletions

View File

@@ -60,7 +60,7 @@ func init() {
}
func TestTracerFollowsExpectedAPIBehaviour(t *testing.T) {
tp := NewProvider(WithConfig(Config{DefaultSampler: TraceIDRatioBased(0)}))
tp := NewTracerProvider(WithConfig(Config{DefaultSampler: TraceIDRatioBased(0)}))
harness := apitest.NewHarness(t)
subjectFactory := func() trace.Tracer {
return tp.Tracer("")
@@ -151,7 +151,7 @@ func (ts testSampler) Description() string {
func TestSetName(t *testing.T) {
fooSampler := &testSampler{prefix: "foo", t: t}
tp := NewProvider(WithConfig(Config{DefaultSampler: fooSampler}))
tp := NewTracerProvider(WithConfig(Config{DefaultSampler: fooSampler}))
type testCase struct {
name string
@@ -206,7 +206,7 @@ func TestSetName(t *testing.T) {
}
func TestRecordingIsOn(t *testing.T) {
tp := NewProvider()
tp := NewTracerProvider()
_, span := tp.Tracer("Recording on").Start(context.Background(), "StartSpan")
defer span.End()
if span.IsRecording() == false {
@@ -259,7 +259,7 @@ func TestSampling(t *testing.T) {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
p := NewProvider(WithConfig(Config{DefaultSampler: tc.sampler}))
p := NewTracerProvider(WithConfig(Config{DefaultSampler: tc.sampler}))
tr := p.Tracer("test")
var sampled int
for i := 0; i < total; i++ {
@@ -297,7 +297,7 @@ func TestSampling(t *testing.T) {
}
func TestStartSpanWithParent(t *testing.T) {
tp := NewProvider()
tp := NewTracerProvider()
tr := tp.Tracer("SpanWithParent")
ctx := context.Background()
@@ -341,7 +341,7 @@ func TestStartSpanWithParent(t *testing.T) {
func TestSetSpanAttributesOnStart(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te))
tp := NewTracerProvider(WithSyncer(te))
span := startSpan(tp,
"StartSpanAttribute",
apitrace.WithAttributes(label.String("key1", "value1")),
@@ -374,7 +374,7 @@ func TestSetSpanAttributesOnStart(t *testing.T) {
func TestSetSpanAttributes(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te))
tp := NewTracerProvider(WithSyncer(te))
span := startSpan(tp, "SpanAttribute")
span.SetAttributes(label.String("key1", "value1"))
got, err := endSpan(te, span)
@@ -404,7 +404,7 @@ func TestSetSpanAttributes(t *testing.T) {
func TestSetSpanAttributesOverLimit(t *testing.T) {
te := NewTestExporter()
cfg := Config{MaxAttributesPerSpan: 2}
tp := NewProvider(WithConfig(cfg), WithSyncer(te))
tp := NewTracerProvider(WithConfig(cfg), WithSyncer(te))
span := startSpan(tp, "SpanAttributesOverLimit")
span.SetAttributes(
@@ -441,7 +441,7 @@ func TestSetSpanAttributesOverLimit(t *testing.T) {
func TestEvents(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te))
tp := NewTracerProvider(WithSyncer(te))
span := startSpan(tp, "Events")
k1v1 := label.String("key1", "value1")
@@ -487,7 +487,7 @@ func TestEvents(t *testing.T) {
func TestEventsOverLimit(t *testing.T) {
te := NewTestExporter()
cfg := Config{MaxEventsPerSpan: 2}
tp := NewProvider(WithConfig(cfg), WithSyncer(te))
tp := NewTracerProvider(WithConfig(cfg), WithSyncer(te))
span := startSpan(tp, "EventsOverLimit")
k1v1 := label.String("key1", "value1")
@@ -538,7 +538,7 @@ func TestEventsOverLimit(t *testing.T) {
func TestLinks(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te))
tp := NewTracerProvider(WithSyncer(te))
k1v1 := label.String("key1", "value1")
k2v2 := label.String("key2", "value2")
@@ -583,7 +583,7 @@ func TestLinksOverLimit(t *testing.T) {
sc2 := apitrace.SpanContext{TraceID: apitrace.ID([16]byte{1, 1}), SpanID: apitrace.SpanID{3}}
sc3 := apitrace.SpanContext{TraceID: apitrace.ID([16]byte{1, 1}), SpanID: apitrace.SpanID{3}}
tp := NewProvider(WithConfig(cfg), WithSyncer(te))
tp := NewTracerProvider(WithConfig(cfg), WithSyncer(te))
span := startSpan(tp, "LinksOverLimit",
apitrace.WithLinks(
@@ -624,7 +624,7 @@ func TestLinksOverLimit(t *testing.T) {
func TestSetSpanName(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te))
tp := NewTracerProvider(WithSyncer(te))
ctx := context.Background()
want := "SpanName-1"
@@ -646,7 +646,7 @@ func TestSetSpanName(t *testing.T) {
func TestSetSpanStatus(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te))
tp := NewTracerProvider(WithSyncer(te))
span := startSpan(tp, "SpanStatus")
span.SetStatus(otelcodes.Canceled, "canceled")
@@ -712,7 +712,7 @@ func checkChild(p apitrace.SpanContext, apiSpan apitrace.Span) error {
// startSpan starts a span with a name "span0". See startNamedSpan for
// details.
func startSpan(tp *Provider, trName string, args ...apitrace.SpanOption) apitrace.Span {
func startSpan(tp *TracerProvider, trName string, args ...apitrace.SpanOption) apitrace.Span {
return startNamedSpan(tp, trName, "span0", args...)
}
@@ -720,7 +720,7 @@ func startSpan(tp *Provider, trName string, args ...apitrace.SpanOption) apitrac
// passed name and with remote span context as parent. The remote span
// context contains TraceFlags with sampled bit set. This allows the
// span to be automatically sampled.
func startNamedSpan(tp *Provider, trName, name string, args ...apitrace.SpanOption) apitrace.Span {
func startNamedSpan(tp *TracerProvider, trName, name string, args ...apitrace.SpanOption) apitrace.Span {
ctx := context.Background()
ctx = apitrace.ContextWithRemoteSpanContext(ctx, remoteSpanContext())
args = append(args, apitrace.WithRecord())
@@ -777,7 +777,7 @@ func checkTime(x *time.Time) bool {
func TestEndSpanTwice(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te))
tp := NewTracerProvider(WithSyncer(te))
span := startSpan(tp, "EndSpanTwice")
span.End()
@@ -789,7 +789,7 @@ func TestEndSpanTwice(t *testing.T) {
func TestStartSpanAfterEnd(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithConfig(Config{DefaultSampler: AlwaysSample()}), WithSyncer(te))
tp := NewTracerProvider(WithConfig(Config{DefaultSampler: AlwaysSample()}), WithSyncer(te))
ctx := context.Background()
tr := tp.Tracer("SpanAfterEnd")
@@ -834,7 +834,7 @@ func TestStartSpanAfterEnd(t *testing.T) {
func TestChildSpanCount(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithConfig(Config{DefaultSampler: AlwaysSample()}), WithSyncer(te))
tp := NewTracerProvider(WithConfig(Config{DefaultSampler: AlwaysSample()}), WithSyncer(te))
tr := tp.Tracer("ChidSpanCount")
ctx, span0 := tr.Start(context.Background(), "parent")
@@ -888,7 +888,7 @@ func TestNilSpanEnd(t *testing.T) {
func TestExecutionTracerTaskEnd(t *testing.T) {
var n uint64
tp := NewProvider(WithConfig(Config{DefaultSampler: NeverSample()}))
tp := NewTracerProvider(WithConfig(Config{DefaultSampler: NeverSample()}))
tr := tp.Tracer("Execution Tracer Task End")
executionTracerTaskEnd := func() {
@@ -937,7 +937,7 @@ func TestExecutionTracerTaskEnd(t *testing.T) {
func TestCustomStartEndTime(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te), WithConfig(Config{DefaultSampler: AlwaysSample()}))
tp := NewTracerProvider(WithSyncer(te), WithConfig(Config{DefaultSampler: AlwaysSample()}))
startTime := time.Date(2019, time.August, 27, 14, 42, 0, 0, time.UTC)
endTime := startTime.Add(time.Second * 20)
@@ -980,7 +980,7 @@ func TestRecordError(t *testing.T) {
for _, s := range scenarios {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te))
tp := NewTracerProvider(WithSyncer(te))
span := startSpan(tp, "RecordError")
errTime := time.Now()
@@ -1022,7 +1022,7 @@ func TestRecordError(t *testing.T) {
func TestRecordErrorWithStatus(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te))
tp := NewTracerProvider(WithSyncer(te))
span := startSpan(tp, "RecordErrorWithStatus")
testErr := ottest.NewTestError("test error")
@@ -1068,7 +1068,7 @@ func TestRecordErrorWithStatus(t *testing.T) {
func TestRecordErrorNil(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te))
tp := NewTracerProvider(WithSyncer(te))
span := startSpan(tp, "RecordErrorNil")
span.RecordError(context.Background(), nil)
@@ -1098,7 +1098,7 @@ func TestRecordErrorNil(t *testing.T) {
func TestWithSpanKind(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te), WithConfig(Config{DefaultSampler: AlwaysSample()}))
tp := NewTracerProvider(WithSyncer(te), WithConfig(Config{DefaultSampler: AlwaysSample()}))
tr := tp.Tracer("withSpanKind")
_, span := tr.Start(context.Background(), "WithoutSpanKind")
@@ -1136,7 +1136,7 @@ func TestWithSpanKind(t *testing.T) {
func TestWithResource(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te),
tp := NewTracerProvider(WithSyncer(te),
WithConfig(Config{DefaultSampler: AlwaysSample()}),
WithResource(resource.New(label.String("rk1", "rv1"), label.Int64("rk2", 5))))
span := startSpan(tp, "WithResource")
@@ -1168,7 +1168,7 @@ func TestWithResource(t *testing.T) {
func TestWithInstrumentationVersion(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te))
tp := NewTracerProvider(WithSyncer(te))
ctx := context.Background()
ctx = apitrace.ContextWithRemoteSpanContext(ctx, remoteSpanContext())
@@ -1202,7 +1202,7 @@ func TestWithInstrumentationVersion(t *testing.T) {
func TestSpanCapturesPanic(t *testing.T) {
te := NewTestExporter()
tp := NewProvider(WithSyncer(te))
tp := NewTracerProvider(WithSyncer(te))
_, span := tp.Tracer("CatchPanic").Start(
context.Background(),
"span",