Skip to content

Commit 3ce4873

Browse files
jamesmoessistraskjack-bergpellared
authored
Propagation - Extract handles multiple values on carrier using same key (#4295)
Fixes #433 Discussed in 11/5/24 Spec SIG, and prototyped in Java and Go. ## Changes Adds `GetAll` method to Getter, allowing for the retrieval of multiple keys for the same value. For example, an HTTP request may have multiple `baggage` headers. As written in the changes, the implementation of `GetAll` is strictly optional. This is for two reasons: 1. Backwards compatibility with existing types/interfaces 2. Carriers do not necessarily support returning multiple values for a single key ## Links to Prototypes This includes implementations of `GetAll()` in Java and Go, as well as using the method in the W3C Baggage Propagators (multiple baggage headers are allowed, [spec reference](https://www.w3.org/TR/baggage/#baggage-http-header-format)). - Java: open-telemetry/opentelemetry-java#6852 - Go: open-telemetry/opentelemetry-go#5973 * [x] Links to the prototypes (when adding or changing features) * [x] [`CHANGELOG.md`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/CHANGELOG.md) file updated for non-trivial changes --------- Co-authored-by: Trask Stalnaker <[email protected]> Co-authored-by: jack-berg <[email protected]> Co-authored-by: Robert Pająk <[email protected]>
1 parent 79380c6 commit 3ce4873

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

Diff for: CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ release.
99

1010
### Context
1111

12+
- Adds optional `GetAll` method to `Getter` in Propagation API, allowing for the retrieval of multiple values for the same key.
13+
[#4295](https://github.com/open-telemetry/opentelemetry-specification/pull/4295)
14+
1215
### Traces
1316

1417
- Add in-development support for `otlp/stdout` exporter via `OTEL_TRACES_EXPORTER`.

Diff for: specification/context/api-propagators.md

+26-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Propagators API
22

3-
**Status**: [Stable, Feature-Freeze](../document-status.md)
3+
**Status**: [Stable](../document-status.md), except where otherwise specified.
44

55
<details>
66
<summary>Table of Contents</summary>
@@ -22,6 +22,7 @@
2222
+ [Getter argument](#getter-argument)
2323
- [Keys](#keys)
2424
- [Get](#get)
25+
- [GetAll](#getall)
2526
- [Injectors and Extractors as Separate Interfaces](#injectors-and-extractors-as-separate-interfaces)
2627
- [Composite Propagator](#composite-propagator)
2728
* [Create a Composite Propagator](#create-a-composite-propagator)
@@ -196,11 +197,11 @@ Returns a new `Context` derived from the `Context` passed as argument.
196197

197198
#### Getter argument
198199

199-
Getter is an argument in `Extract` that get value from given field
200+
Getter is an argument in `Extract` that gets value(s) from given field.
200201

201202
`Getter` allows a `TextMapPropagator` to read propagated fields from a carrier.
202203

203-
One of the ways to implement it is `Getter` class with `Get` and `Keys` methods
204+
One of the ways to implement it is `Getter` class with methods `Get`, `Keys`, and `GetAll`
204205
as described below. Languages may decide on alternative implementations and
205206
expose corresponding methods as delegates or other ways.
206207

@@ -227,7 +228,28 @@ Required arguments:
227228
- the carrier of propagation fields, such as an HTTP request.
228229
- the key of the field.
229230

230-
The Get function is responsible for handling case sensitivity. If the getter is intended to work with a HTTP request object, the getter MUST be case insensitive.
231+
The Get function is responsible for handling case sensitivity. If the getter is intended to work with an HTTP request object, the getter MUST be case insensitive.
232+
233+
##### GetAll
234+
235+
**Status**: [Development](../document-status.md)
236+
237+
For many language implementations, the `GetAll` function will be added after the stable release of `Getter`.
238+
For these languages, requiring implementations of `Getter` to include `GetAll` constitutes a breaking change
239+
since instrumentation which previously functioned would fail. Language implementations should be cognizant
240+
of this, and add `GetAll` in a way that retains backwards compatibility. For example, by providing a default
241+
`GetAll` implementation based on Get, or by creating an extended `Getter` type.
242+
243+
If explicitly implemented, the `GetAll` function MUST return all values of the given propagation key.
244+
It SHOULD return them in the same order as they appear in the carrier.
245+
If the key doesn't exist, it SHOULD return an empty collection.
246+
247+
Required arguments:
248+
249+
- the carrier of propagation fields, such as an HTTP request.
250+
- the key of the field.
251+
252+
The `GetAll` function is responsible for handling case sensitivity. If the getter is intended to work with an HTTP request object, the getter MUST be case insensitive.
231253

232254
## Injectors and Extractors as Separate Interfaces
233255

0 commit comments

Comments
 (0)