From f7f74fcf006d0c9fd2b3e3ef8653e0f733f4ceb3 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Wed, 21 Jul 2021 11:26:32 -0700 Subject: [PATCH 1/3] Add propagationtest package --- oteltest/text_map_propagator.go | 10 ++ propagation/propagationtest/doc.go | 23 +++ .../propagationtest/text_map_carrier.go | 141 ++++++++++++++++++ .../propagationtest/text_map_carrier_test.go | 83 +++++++++++ .../propagationtest/text_map_propagator.go | 112 ++++++++++++++ .../text_map_propagator_test.go | 69 +++++++++ 6 files changed, 438 insertions(+) create mode 100644 propagation/propagationtest/doc.go create mode 100644 propagation/propagationtest/text_map_carrier.go create mode 100644 propagation/propagationtest/text_map_carrier_test.go create mode 100644 propagation/propagationtest/text_map_propagator.go create mode 100644 propagation/propagationtest/text_map_propagator_test.go diff --git a/oteltest/text_map_propagator.go b/oteltest/text_map_propagator.go index 4803ad18f73..153fd4602c1 100644 --- a/oteltest/text_map_propagator.go +++ b/oteltest/text_map_propagator.go @@ -29,6 +29,8 @@ type ctxKeyType string // TextMapCarrier provides a testing storage medium to for a // TextMapPropagator. It records all the operations it performs. +// +// Deprecated: use the propagationtest package instead. type TextMapCarrier struct { mtx sync.Mutex @@ -38,6 +40,8 @@ type TextMapCarrier struct { } // NewTextMapCarrier returns a new *TextMapCarrier populated with data. +// +// Deprecated: use the propagationtest package instead. func NewTextMapCarrier(data map[string]string) *TextMapCarrier { copied := make(map[string]string, len(data)) for k, v := range data { @@ -161,11 +165,17 @@ func (s state) String() string { return fmt.Sprintf("%d,%d", s.Injections, s.Extractions) } +// TextMapPropagator is a propagation.TextMapPropagator used for testing. +// +// Deprecated: use the propagationtest package instead. type TextMapPropagator struct { Name string ctxKey ctxKeyType } +// NewTextMapPropagator returns a new TextMapPropagator for testing. +// +// Deprecated: use the propagationtest package instead. func NewTextMapPropagator(name string) *TextMapPropagator { return &TextMapPropagator{Name: name, ctxKey: ctxKeyType(name)} } diff --git a/propagation/propagationtest/doc.go b/propagation/propagationtest/doc.go new file mode 100644 index 00000000000..ca8f1893d6e --- /dev/null +++ b/propagation/propagationtest/doc.go @@ -0,0 +1,23 @@ +// 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 propagationtest provides testing utilities for the propagation +package. + +This package is currently in a Release Candidate phase. Backwards incompatible +changes may be introduced prior to v1.0.0, but we believe the current API is +ready to stabilize. +*/ +package propagationtest diff --git a/propagation/propagationtest/text_map_carrier.go b/propagation/propagationtest/text_map_carrier.go new file mode 100644 index 00000000000..ce291fb0026 --- /dev/null +++ b/propagation/propagationtest/text_map_carrier.go @@ -0,0 +1,141 @@ +// 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 propagationtest + +import ( + "sync" + "testing" + + "go.opentelemetry.io/otel/propagation" +) + +// TextMapCarrier is a storage medium for a TextMapPropagator used in testing. +// The methods of a TextMapCarrier are concurrent safe. +type TextMapCarrier struct { + mtx sync.Mutex + + gets []string + sets [][2]string + data map[string]string +} + +var _ propagation.TextMapCarrier = (*TextMapCarrier)(nil) + +// NewTextMapCarrier returns a new *TextMapCarrier populated with data. +func NewTextMapCarrier(data map[string]string) *TextMapCarrier { + copied := make(map[string]string, len(data)) + for k, v := range data { + copied[k] = v + } + return &TextMapCarrier{data: copied} +} + +// Keys returns the keys for which this carrier has a value. +func (c *TextMapCarrier) Keys() []string { + c.mtx.Lock() + defer c.mtx.Unlock() + + result := make([]string, 0, len(c.data)) + for k := range c.data { + result = append(result, k) + } + return result +} + +// Get returns the value associated with the passed key. +func (c *TextMapCarrier) Get(key string) string { + c.mtx.Lock() + defer c.mtx.Unlock() + c.gets = append(c.gets, key) + return c.data[key] +} + +// GotKey tests if c.Get has been called for key. +func (c *TextMapCarrier) GotKey(t *testing.T, key string) bool { + c.mtx.Lock() + defer c.mtx.Unlock() + for _, k := range c.gets { + if k == key { + return true + } + } + t.Errorf("TextMapCarrier.Get(%q) has not been called", key) + return false +} + +// GotN tests if n calls to c.Get have been made. +func (c *TextMapCarrier) GotN(t *testing.T, n int) bool { + c.mtx.Lock() + defer c.mtx.Unlock() + if len(c.gets) != n { + t.Errorf("TextMapCarrier.Get was called %d times, not %d", len(c.gets), n) + return false + } + return true +} + +// Set stores the key-value pair. +func (c *TextMapCarrier) Set(key, value string) { + c.mtx.Lock() + defer c.mtx.Unlock() + c.sets = append(c.sets, [2]string{key, value}) + c.data[key] = value +} + +// SetKeyValue tests if c.Set has been called for the key-value pair. +func (c *TextMapCarrier) SetKeyValue(t *testing.T, key, value string) bool { + c.mtx.Lock() + defer c.mtx.Unlock() + var vals []string + for _, pair := range c.sets { + if key == pair[0] { + if value == pair[1] { + return true + } + vals = append(vals, pair[1]) + } + } + if len(vals) > 0 { + t.Errorf("TextMapCarrier.Set called with %q and %v values, but not %s", key, vals, value) + } + t.Errorf("TextMapCarrier.Set(%q,%q) has not been called", key, value) + return false +} + +// SetN tests if n calls to c.Set have been made. +func (c *TextMapCarrier) SetN(t *testing.T, n int) bool { + c.mtx.Lock() + defer c.mtx.Unlock() + if len(c.sets) != n { + t.Errorf("TextMapCarrier.Set was called %d times, not %d", len(c.sets), n) + return false + } + return true +} + +// Reset zeros out the recording state and sets the carried values to data. +func (c *TextMapCarrier) Reset(data map[string]string) { + copied := make(map[string]string, len(data)) + for k, v := range data { + copied[k] = v + } + + c.mtx.Lock() + defer c.mtx.Unlock() + + c.gets = nil + c.sets = nil + c.data = copied +} diff --git a/propagation/propagationtest/text_map_carrier_test.go b/propagation/propagationtest/text_map_carrier_test.go new file mode 100644 index 00000000000..05833632ac0 --- /dev/null +++ b/propagation/propagationtest/text_map_carrier_test.go @@ -0,0 +1,83 @@ +// 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 propagationtest + +import ( + "reflect" + "testing" +) + +var ( + key, value = "test", "true" +) + +func TestTextMapCarrierKeys(t *testing.T) { + tmc := NewTextMapCarrier(map[string]string{key: value}) + expected, actual := []string{key}, tmc.Keys() + if !reflect.DeepEqual(actual, expected) { + t.Errorf("expected tmc.Keys() to be %v but it was %v", expected, actual) + } +} + +func TestTextMapCarrierGet(t *testing.T) { + tmc := NewTextMapCarrier(map[string]string{key: value}) + tmc.GotN(t, 0) + if got := tmc.Get("empty"); got != "" { + t.Errorf("TextMapCarrier.Get returned %q for an empty key", got) + } + tmc.GotKey(t, "empty") + tmc.GotN(t, 1) + if got := tmc.Get(key); got != value { + t.Errorf("TextMapCarrier.Get(%q) returned %q, want %q", key, got, value) + } + tmc.GotKey(t, key) + tmc.GotN(t, 2) +} + +func TestTextMapCarrierSet(t *testing.T) { + tmc := NewTextMapCarrier(nil) + tmc.SetN(t, 0) + tmc.Set(key, value) + if got, ok := tmc.data[key]; !ok { + t.Errorf("TextMapCarrier.Set(%q,%q) failed to store pair", key, value) + } else if got != value { + t.Errorf("TextMapCarrier.Set(%q,%q) stored (%q,%q), not (%q,%q)", key, value, key, got, key, value) + } + tmc.SetKeyValue(t, key, value) + tmc.SetN(t, 1) +} + +func TestTextMapCarrierReset(t *testing.T) { + tmc := NewTextMapCarrier(map[string]string{key: value}) + tmc.GotN(t, 0) + tmc.SetN(t, 0) + tmc.Reset(nil) + tmc.GotN(t, 0) + tmc.SetN(t, 0) + if got := tmc.Get(key); got != "" { + t.Error("TextMapCarrier.Reset() failed to clear initial data") + } + tmc.GotN(t, 1) + tmc.GotKey(t, key) + tmc.Set(key, value) + tmc.SetKeyValue(t, key, value) + tmc.SetN(t, 1) + tmc.Reset(nil) + tmc.GotN(t, 0) + tmc.SetN(t, 0) + if got := tmc.Get(key); got != "" { + t.Error("TextMapCarrier.Reset() failed to clear data") + } +} diff --git a/propagation/propagationtest/text_map_propagator.go b/propagation/propagationtest/text_map_propagator.go new file mode 100644 index 00000000000..1e64dd42b85 --- /dev/null +++ b/propagation/propagationtest/text_map_propagator.go @@ -0,0 +1,112 @@ +// 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 propagationtest + +import ( + "context" + "fmt" + "strconv" + "strings" + "testing" + + "go.opentelemetry.io/otel/propagation" +) + +type ctxKeyType string + +type state struct { + Injections uint64 + Extractions uint64 +} + +func newState(encoded string) state { + if encoded == "" { + return state{} + } + split := strings.SplitN(encoded, ",", 2) + injects, _ := strconv.ParseUint(split[0], 10, 64) + extracts, _ := strconv.ParseUint(split[1], 10, 64) + return state{ + Injections: injects, + Extractions: extracts, + } +} + +func (s state) String() string { + return fmt.Sprintf("%d,%d", s.Injections, s.Extractions) +} + +// TextMapPropagator is a propagation.TextMapPropagator used for testing. +type TextMapPropagator struct { + name string + ctxKey ctxKeyType +} + +var _ propagation.TextMapPropagator = (*TextMapPropagator)(nil) + +// NewTextMapPropagator returns a new TextMapPropagator for testing. It will +// use name as the key it injects into a TextMapCarrier when Inject is called. +func NewTextMapPropagator(name string) *TextMapPropagator { + return &TextMapPropagator{name: name, ctxKey: ctxKeyType(name)} +} + +func (p *TextMapPropagator) stateFromContext(ctx context.Context) state { + if v := ctx.Value(p.ctxKey); v != nil { + if s, ok := v.(state); ok { + return s + } + } + return state{} +} + +func (p *TextMapPropagator) stateFromCarrier(carrier propagation.TextMapCarrier) state { + return newState(carrier.Get(p.name)) +} + +// Inject sets cross-cutting concerns for p from ctx into carrier. +func (p *TextMapPropagator) Inject(ctx context.Context, carrier propagation.TextMapCarrier) { + s := p.stateFromContext(ctx) + s.Injections++ + carrier.Set(p.name, s.String()) +} + +// InjectedN tests if p has made n injections to carrier. +func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n int) bool { + if actual := p.stateFromCarrier(carrier).Injections; actual != uint64(n) { + t.Errorf("TextMapPropagator{%q} injected %d times, not %d", p.name, actual, n) + return false + } + return true +} + +// Extract reads cross-cutting concerns for p from carrier into ctx. +func (p *TextMapPropagator) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context { + s := p.stateFromCarrier(carrier) + s.Extractions++ + return context.WithValue(ctx, p.ctxKey, s) +} + +// ExtractedN tests if p has made n extractions from the lineage of ctx. +// nolint (context is not first arg) +func (p *TextMapPropagator) ExtractedN(t *testing.T, ctx context.Context, n int) bool { + if actual := p.stateFromContext(ctx).Extractions; actual != uint64(n) { + t.Errorf("TextMapPropagator{%q} extracted %d time, not %d", p.name, actual, n) + return false + } + return true +} + +// Fields returns the name of p as the key who's value is set with Inject. +func (p *TextMapPropagator) Fields() []string { return []string{p.name} } diff --git a/propagation/propagationtest/text_map_propagator_test.go b/propagation/propagationtest/text_map_propagator_test.go new file mode 100644 index 00000000000..4b17ba8d74e --- /dev/null +++ b/propagation/propagationtest/text_map_propagator_test.go @@ -0,0 +1,69 @@ +// 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 propagationtest + +import ( + "context" + "testing" +) + +func TestTextMapPropagatorInjectExtract(t *testing.T) { + name := "testing" + ctx := context.Background() + carrier := NewTextMapCarrier(map[string]string{name: value}) + propagator := NewTextMapPropagator(name) + + propagator.Inject(ctx, carrier) + // Carrier value overridden with state. + if carrier.SetKeyValue(t, name, "1,0") { + // Ensure nothing has been extracted yet. + propagator.ExtractedN(t, ctx, 0) + // Test the injection was counted. + propagator.InjectedN(t, carrier, 1) + } + + ctx = propagator.Extract(ctx, carrier) + v := ctx.Value(ctxKeyType(name)) + if v == nil { + t.Error("TextMapPropagator.Extract failed to extract state") + } + if s, ok := v.(state); !ok { + t.Error("TextMapPropagator.Extract did not extract proper state") + } else if s.Extractions != 1 { + t.Error("TextMapPropagator.Extract did not increment state.Extractions") + } + if carrier.GotKey(t, name) { + // Test the extraction was counted. + propagator.ExtractedN(t, ctx, 1) + // Ensure no additional injection was recorded. + propagator.InjectedN(t, carrier, 1) + } +} + +func TestTextMapPropagatorFields(t *testing.T) { + name := "testing" + propagator := NewTextMapPropagator(name) + if got := propagator.Fields(); len(got) != 1 { + t.Errorf("TextMapPropagator.Fields returned %d fields, want 1", len(got)) + } else if got[0] != name { + t.Errorf("TextMapPropagator.Fields returned %q, want %q", got[0], name) + } +} + +func TestNewStateEmpty(t *testing.T) { + if want, got := (state{}), newState(""); got != want { + t.Errorf("newState(\"\") returned %v, want %v", got, want) + } +} From 71cd299d5545064fe1f367ecff2ff2dcedb64e7e Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Wed, 21 Jul 2021 11:32:26 -0700 Subject: [PATCH 2/3] Update internal/global to use propagationtest --- internal/global/propagator_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/global/propagator_test.go b/internal/global/propagator_test.go index 1089c896ac3..9c1def03db3 100644 --- a/internal/global/propagator_test.go +++ b/internal/global/propagator_test.go @@ -19,13 +19,13 @@ import ( "testing" "go.opentelemetry.io/otel/internal/global" - "go.opentelemetry.io/otel/oteltest" + "go.opentelemetry.io/otel/propagation/propagationtest" ) func TestTextMapPropagatorDelegation(t *testing.T) { global.ResetForTest() ctx := context.Background() - carrier := oteltest.NewTextMapCarrier(nil) + carrier := propagationtest.NewTextMapCarrier(nil) // The default should be a noop. initial := global.TextMapPropagator() @@ -36,7 +36,7 @@ func TestTextMapPropagatorDelegation(t *testing.T) { } // Make sure the delegate woks as expected. - delegate := oteltest.NewTextMapPropagator("test") + delegate := propagationtest.NewTextMapPropagator("test") delegate.Inject(ctx, carrier) ctx = delegate.Extract(ctx, carrier) if !delegate.InjectedN(t, carrier, 1) || !delegate.ExtractedN(t, ctx, 1) { @@ -55,7 +55,7 @@ func TestTextMapPropagatorDelegation(t *testing.T) { func TestTextMapPropagatorDelegationNil(t *testing.T) { global.ResetForTest() ctx := context.Background() - carrier := oteltest.NewTextMapCarrier(nil) + carrier := propagationtest.NewTextMapCarrier(nil) // The default should be a noop. initial := global.TextMapPropagator() @@ -77,7 +77,7 @@ func TestTextMapPropagatorDelegationNil(t *testing.T) { func TestTextMapPropagatorFields(t *testing.T) { global.ResetForTest() initial := global.TextMapPropagator() - delegate := oteltest.NewTextMapPropagator("test") + delegate := propagationtest.NewTextMapPropagator("test") delegateFields := delegate.Fields() // Sanity check on the initial Fields. From 99f3e6a241441ed40dec81310eb1c8f57d416a2e Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Wed, 21 Jul 2021 13:09:34 -0700 Subject: [PATCH 3/3] Move propagationtest into internal --- CHANGELOG.md | 2 ++ internal/global/propagator_test.go | 10 ++++---- .../internaltest}/text_map_carrier.go | 2 +- .../internaltest}/text_map_carrier_test.go | 2 +- .../internaltest}/text_map_propagator.go | 2 +- .../internaltest}/text_map_propagator_test.go | 2 +- oteltest/text_map_propagator.go | 8 +++---- propagation/propagationtest/doc.go | 23 ------------------- 8 files changed, 15 insertions(+), 36 deletions(-) rename {propagation/propagationtest => internal/internaltest}/text_map_carrier.go (99%) rename {propagation/propagationtest => internal/internaltest}/text_map_carrier_test.go (98%) rename {propagation/propagationtest => internal/internaltest}/text_map_propagator.go (99%) rename {propagation/propagationtest => internal/internaltest}/text_map_propagator_test.go (98%) delete mode 100644 propagation/propagationtest/doc.go diff --git a/CHANGELOG.md b/CHANGELOG.md index c7b17d34b56..7219c962d11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Deprecated +- The `TextMapCarrier` and `TextMapPropagator` from the `go.opentelemetry.io/otel/oteltest` package and their associated creation functions (`TextMapCarrier`, `NewTextMapPropagator`) are deprecated. (#2114) + ### Removed - Removed the deprecated package `go.opentelemetry.io/otel/exporters/trace/jaeger`. (#2020) diff --git a/internal/global/propagator_test.go b/internal/global/propagator_test.go index 9c1def03db3..afaff13e4a2 100644 --- a/internal/global/propagator_test.go +++ b/internal/global/propagator_test.go @@ -19,13 +19,13 @@ import ( "testing" "go.opentelemetry.io/otel/internal/global" - "go.opentelemetry.io/otel/propagation/propagationtest" + "go.opentelemetry.io/otel/internal/internaltest" ) func TestTextMapPropagatorDelegation(t *testing.T) { global.ResetForTest() ctx := context.Background() - carrier := propagationtest.NewTextMapCarrier(nil) + carrier := internaltest.NewTextMapCarrier(nil) // The default should be a noop. initial := global.TextMapPropagator() @@ -36,7 +36,7 @@ func TestTextMapPropagatorDelegation(t *testing.T) { } // Make sure the delegate woks as expected. - delegate := propagationtest.NewTextMapPropagator("test") + delegate := internaltest.NewTextMapPropagator("test") delegate.Inject(ctx, carrier) ctx = delegate.Extract(ctx, carrier) if !delegate.InjectedN(t, carrier, 1) || !delegate.ExtractedN(t, ctx, 1) { @@ -55,7 +55,7 @@ func TestTextMapPropagatorDelegation(t *testing.T) { func TestTextMapPropagatorDelegationNil(t *testing.T) { global.ResetForTest() ctx := context.Background() - carrier := propagationtest.NewTextMapCarrier(nil) + carrier := internaltest.NewTextMapCarrier(nil) // The default should be a noop. initial := global.TextMapPropagator() @@ -77,7 +77,7 @@ func TestTextMapPropagatorDelegationNil(t *testing.T) { func TestTextMapPropagatorFields(t *testing.T) { global.ResetForTest() initial := global.TextMapPropagator() - delegate := propagationtest.NewTextMapPropagator("test") + delegate := internaltest.NewTextMapPropagator("test") delegateFields := delegate.Fields() // Sanity check on the initial Fields. diff --git a/propagation/propagationtest/text_map_carrier.go b/internal/internaltest/text_map_carrier.go similarity index 99% rename from propagation/propagationtest/text_map_carrier.go rename to internal/internaltest/text_map_carrier.go index ce291fb0026..198a00230a6 100644 --- a/propagation/propagationtest/text_map_carrier.go +++ b/internal/internaltest/text_map_carrier.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package propagationtest +package internaltest import ( "sync" diff --git a/propagation/propagationtest/text_map_carrier_test.go b/internal/internaltest/text_map_carrier_test.go similarity index 98% rename from propagation/propagationtest/text_map_carrier_test.go rename to internal/internaltest/text_map_carrier_test.go index 05833632ac0..9f8832869b6 100644 --- a/propagation/propagationtest/text_map_carrier_test.go +++ b/internal/internaltest/text_map_carrier_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package propagationtest +package internaltest import ( "reflect" diff --git a/propagation/propagationtest/text_map_propagator.go b/internal/internaltest/text_map_propagator.go similarity index 99% rename from propagation/propagationtest/text_map_propagator.go rename to internal/internaltest/text_map_propagator.go index 1e64dd42b85..76ba80b3a8d 100644 --- a/propagation/propagationtest/text_map_propagator.go +++ b/internal/internaltest/text_map_propagator.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package propagationtest +package internaltest import ( "context" diff --git a/propagation/propagationtest/text_map_propagator_test.go b/internal/internaltest/text_map_propagator_test.go similarity index 98% rename from propagation/propagationtest/text_map_propagator_test.go rename to internal/internaltest/text_map_propagator_test.go index 4b17ba8d74e..7332787f62e 100644 --- a/propagation/propagationtest/text_map_propagator_test.go +++ b/internal/internaltest/text_map_propagator_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package propagationtest +package internaltest import ( "context" diff --git a/oteltest/text_map_propagator.go b/oteltest/text_map_propagator.go index 153fd4602c1..c919c449d3c 100644 --- a/oteltest/text_map_propagator.go +++ b/oteltest/text_map_propagator.go @@ -30,7 +30,7 @@ type ctxKeyType string // TextMapCarrier provides a testing storage medium to for a // TextMapPropagator. It records all the operations it performs. // -// Deprecated: use the propagationtest package instead. +// Deprecated: this will be removed in the next major release. type TextMapCarrier struct { mtx sync.Mutex @@ -41,7 +41,7 @@ type TextMapCarrier struct { // NewTextMapCarrier returns a new *TextMapCarrier populated with data. // -// Deprecated: use the propagationtest package instead. +// Deprecated: this will be removed in the next major release. func NewTextMapCarrier(data map[string]string) *TextMapCarrier { copied := make(map[string]string, len(data)) for k, v := range data { @@ -167,7 +167,7 @@ func (s state) String() string { // TextMapPropagator is a propagation.TextMapPropagator used for testing. // -// Deprecated: use the propagationtest package instead. +// Deprecated: this will be removed in the next major release. type TextMapPropagator struct { Name string ctxKey ctxKeyType @@ -175,7 +175,7 @@ type TextMapPropagator struct { // NewTextMapPropagator returns a new TextMapPropagator for testing. // -// Deprecated: use the propagationtest package instead. +// Deprecated: this will be removed in the next major release. func NewTextMapPropagator(name string) *TextMapPropagator { return &TextMapPropagator{Name: name, ctxKey: ctxKeyType(name)} } diff --git a/propagation/propagationtest/doc.go b/propagation/propagationtest/doc.go deleted file mode 100644 index ca8f1893d6e..00000000000 --- a/propagation/propagationtest/doc.go +++ /dev/null @@ -1,23 +0,0 @@ -// 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 propagationtest provides testing utilities for the propagation -package. - -This package is currently in a Release Candidate phase. Backwards incompatible -changes may be introduced prior to v1.0.0, but we believe the current API is -ready to stabilize. -*/ -package propagationtest