File tree Expand file tree Collapse file tree 3 files changed +45
-3
lines changed
src/opentelemetry/baggage/propagation Expand file tree Collapse file tree 3 files changed +45
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
9
9
- ` opentelemetry-semantic-conventions ` Update to semantic conventions v1.6.1
10
10
([ #2077 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/2077 ) )
11
+ - Fix propagation bug caused by counting skipped entries
12
+ ([ #2071 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/2071 ) )
11
13
12
14
## [ 1.5.0-0.24b0] ( https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.5.0-0.24b0 ) - 2021-08-26
13
15
Original file line number Diff line number Diff line change @@ -54,9 +54,6 @@ def extract(
54
54
baggage_entries = header .split ("," )
55
55
total_baggage_entries = self ._MAX_PAIRS
56
56
for entry in baggage_entries :
57
- if total_baggage_entries <= 0 :
58
- return context
59
- total_baggage_entries -= 1
60
57
if len (entry ) > self ._MAX_PAIR_LENGTH :
61
58
continue
62
59
try :
@@ -68,6 +65,9 @@ def extract(
68
65
unquote_plus (value ).strip (),
69
66
context = context ,
70
67
)
68
+ total_baggage_entries -= 1
69
+ if total_baggage_entries == 0 :
70
+ break
71
71
72
72
return context
73
73
Original file line number Diff line number Diff line change @@ -118,6 +118,46 @@ def test_extract_unquote_plus(self):
118
118
{"key/key" : "value/value" },
119
119
)
120
120
121
+ def test_header_max_entries_skip_invalid_entry (self ):
122
+
123
+ self .assertEqual (
124
+ self ._extract (
125
+ "," .join (
126
+ [
127
+ f"key{ index } =value{ index } "
128
+ if index != 2
129
+ else (
130
+ f"key{ index } ="
131
+ f"value{ 's' * (W3CBaggagePropagator ._MAX_PAIR_LENGTH + 1 )} "
132
+ )
133
+ for index in range (W3CBaggagePropagator ._MAX_PAIRS + 1 )
134
+ ]
135
+ )
136
+ ),
137
+ {
138
+ f"key{ index } " : f"value{ index } "
139
+ for index in range (W3CBaggagePropagator ._MAX_PAIRS + 1 )
140
+ if index != 2
141
+ },
142
+ )
143
+ self .assertEqual (
144
+ self ._extract (
145
+ "," .join (
146
+ [
147
+ f"key{ index } =value{ index } "
148
+ if index != 2
149
+ else f"key{ index } xvalue{ index } "
150
+ for index in range (W3CBaggagePropagator ._MAX_PAIRS + 1 )
151
+ ]
152
+ )
153
+ ),
154
+ {
155
+ f"key{ index } " : f"value{ index } "
156
+ for index in range (W3CBaggagePropagator ._MAX_PAIRS + 1 )
157
+ if index != 2
158
+ },
159
+ )
160
+
121
161
def test_inject_no_baggage_entries (self ):
122
162
values = {}
123
163
output = self ._inject (values )
You can’t perform that action at this time.
0 commit comments