Skip to content

Commit 3376533

Browse files
authored
Specify allowed characters for Baggage keys and values (#3801)
## Changes * Add missing spec language on what keys and values are allowed for the baggage. * Emphasize case sensitivity * Definitions are aligned with W3C Baggage Spec, but provide a distinction between API representation and the wire encoding (done by W3C Propagator)
1 parent a1c13d5 commit 3376533

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ release.
9191

9292
- Align definition of Baggage with W3C Specification.
9393
([#3800](https://github.com/open-telemetry/opentelemetry-specification/pull/3800))
94+
- Specify allowed characters for Baggage keys and values.
95+
([#3801](https://github.com/open-telemetry/opentelemetry-specification/pull/3801))
9496

9597
### Traces
9698

specification/baggage/api.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,32 @@ with _exactly one value_. This is more restrictive than the [W3C Baggage
3535
Specification, § 3.2.1.1](https://www.w3.org/TR/baggage/#baggage-string)
3636
which allows duplicate entries for a given name.
3737

38+
Baggage **names** are any valid UTF-8 strings. Language API SHOULD NOT
39+
restrict which strings are used as baggage **names**. However, the
40+
specific `Propagator`s that are used to transmit baggage entries across
41+
component boundaries may impose their own restrictions on baggage names.
42+
For example, the [W3C Baggage specification](https://www.w3.org/TR/baggage/#key)
43+
restricts the baggage keys to strings that satisfy the `token` definition
44+
from [RFC7230, Section 3.2.6](https://tools.ietf.org/html/rfc7230#section-3.2.6).
45+
For maximum compatibility, alpha-numeric names are strongly recommended
46+
to be used as baggage names.
47+
48+
Baggage **values** are any valid UTF-8 strings. Language API MUST accept
49+
any valid UTF-8 string as baggage **value** in `Set` and return the same
50+
value from `Get`.
51+
52+
Language API MUST treat both baggage names and values as case sensitive.
53+
See also [W3C Baggage Rationale](https://github.com/w3c/baggage/blob/main/baggage/HTTP_HEADER_FORMAT_RATIONALE.md#case-sensitivity-of-keys).
54+
55+
Example:
56+
57+
```
58+
baggage.Set('a', 'B% 💼');
59+
baggage.Set('A', 'c');
60+
baggage.Get('a'); // returns "B% 💼"
61+
baggage.Get('A'); // returns "c"
62+
```
63+
3864
The Baggage API consists of:
3965

4066
- the `Baggage` as a logical container

0 commit comments

Comments
 (0)