@@ -13,7 +13,7 @@ import (
13
13
"github.com/stretchr/testify/require"
14
14
15
15
"go.opentelemetry.io/otel/attribute"
16
- otelbaggage "go.opentelemetry.io/otel/baggage"
16
+ "go.opentelemetry.io/otel/baggage"
17
17
"go.opentelemetry.io/otel/sdk/trace"
18
18
"go.opentelemetry.io/otel/sdk/trace/tracetest"
19
19
)
@@ -37,9 +37,9 @@ func NewTestExporter() *testExporter {
37
37
}
38
38
39
39
func TestSpanProcessorAppendsAllBaggageAttributes (t * testing.T ) {
40
- baggage , _ := otelbaggage .New ()
41
- baggage = addEntryToBaggage (t , baggage , "baggage.test" , "baggage value" )
42
- ctx := otelbaggage .ContextWithBaggage (context .Background (), baggage )
40
+ b , _ := baggage .New ()
41
+ b = addEntryToBaggage (t , b , "baggage.test" , "baggage value" )
42
+ ctx := baggage .ContextWithBaggage (context .Background (), b )
43
43
44
44
// create trace provider with baggage processor and test exporter
45
45
exporter := NewTestExporter ()
@@ -61,9 +61,9 @@ func TestSpanProcessorAppendsAllBaggageAttributes(t *testing.T) {
61
61
}
62
62
63
63
func TestSpanProcessorAppendsBaggageAttributesWithHaPrefixPredicate (t * testing.T ) {
64
- baggage , _ := otelbaggage .New ()
65
- baggage = addEntryToBaggage (t , baggage , "baggage.test" , "baggage value" )
66
- ctx := otelbaggage .ContextWithBaggage (context .Background (), baggage )
64
+ b , _ := baggage .New ()
65
+ b = addEntryToBaggage (t , b , "baggage.test" , "baggage value" )
66
+ ctx := baggage .ContextWithBaggage (context .Background (), b )
67
67
68
68
baggageKeyPredicate := func (m otelbaggage.Member ) bool {
69
69
return strings .HasPrefix (m .Key (), "baggage." )
@@ -89,9 +89,9 @@ func TestSpanProcessorAppendsBaggageAttributesWithHaPrefixPredicate(t *testing.T
89
89
}
90
90
91
91
func TestSpanProcessorAppendsBaggageAttributesWithRegexPredicate (t * testing.T ) {
92
- baggage , _ := otelbaggage .New ()
93
- baggage = addEntryToBaggage (t , baggage , "baggage.test" , "baggage value" )
94
- ctx := otelbaggage .ContextWithBaggage (context .Background (), baggage )
92
+ b , _ := baggage .New ()
93
+ b = addEntryToBaggage (t , b , "baggage.test" , "baggage value" )
94
+ ctx := baggage .ContextWithBaggage (context .Background (), b )
95
95
96
96
expr := regexp .MustCompile (`^baggage\..*` )
97
97
baggageKeyPredicate := func (m otelbaggage.Member ) bool {
@@ -118,10 +118,10 @@ func TestSpanProcessorAppendsBaggageAttributesWithRegexPredicate(t *testing.T) {
118
118
}
119
119
120
120
func TestOnlyAddsBaggageEntriesThatMatchPredicate (t * testing.T ) {
121
- baggage , _ := otelbaggage .New ()
122
- baggage = addEntryToBaggage (t , baggage , "baggage.test" , "baggage value" )
123
- baggage = addEntryToBaggage (t , baggage , "foo" , "bar" )
124
- ctx := otelbaggage .ContextWithBaggage (context .Background (), baggage )
121
+ b , _ := baggage .New ()
122
+ b = addEntryToBaggage (t , b , "baggage.test" , "baggage value" )
123
+ b = addEntryToBaggage (t , b , "foo" , "bar" )
124
+ ctx := baggage .ContextWithBaggage (context .Background (), b )
125
125
126
126
baggageKeyPredicate := func (m otelbaggage.Member ) bool {
127
127
return m .Key () == "baggage.test"
@@ -146,23 +146,23 @@ func TestOnlyAddsBaggageEntriesThatMatchPredicate(t *testing.T) {
146
146
require .Equal (t , want , exporter .spans [0 ].Attributes ()[0 ])
147
147
}
148
148
149
- func addEntryToBaggage (t * testing.T , baggage otelbaggage .Baggage , key , value string ) otelbaggage .Baggage {
150
- member , err := otelbaggage .NewMemberRaw (key , value )
149
+ func addEntryToBaggage (t * testing.T , b baggage .Baggage , key , value string ) baggage .Baggage {
150
+ member , err := baggage .NewMemberRaw (key , value )
151
151
require .NoError (t , err )
152
- baggage , err = baggage .SetMember (member )
152
+ b , err = b .SetMember (member )
153
153
require .NoError (t , err )
154
- return baggage
154
+ return b
155
155
}
156
156
157
157
func TestZeroSpanProcessorNoPanic (t * testing.T ) {
158
158
sp := new (SpanProcessor )
159
159
160
- m , err := otelbaggage .NewMember ("key" , "val" )
160
+ m , err := baggage .NewMember ("key" , "val" )
161
161
require .NoError (t , err )
162
- b , err := otelbaggage .New (m )
162
+ b , err := baggage .New (m )
163
163
require .NoError (t , err )
164
164
165
- ctx := otelbaggage .ContextWithBaggage (context .Background (), b )
165
+ ctx := baggage .ContextWithBaggage (context .Background (), b )
166
166
roS := (tracetest.SpanStub {}).Snapshot ()
167
167
rwS := rwSpan {}
168
168
assert .NotPanics (t , func () {
0 commit comments