Skip to content

Commit 702de19

Browse files
Rename CorrelationContext to Baggage (open-telemetry#857)
* Rename CorrelationContext to Baggage Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com> * Update CHANGELOG.md Co-authored-by: Sergey Kanzhelev <S.Kanzhelev@live.com>
1 parent 6b70eef commit 702de19

File tree

13 files changed

+178
-176
lines changed

13 files changed

+178
-176
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ New:
1818

1919
Updates:
2020

21+
- Renamed `CorrelationContext` to `Baggage`:
22+
([#857](https://github.com/open-telemetry/opentelemetry-specification/pull/857))
2123
- Add semantic convention for NGINX custom HTTP 499 status code.
2224
- Adapt semantic conventions for the span name of messaging systems
2325
([#690](https://github.com/open-telemetry/opentelemetry-specification/pull/690))

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The OpenTelemetry specification describes the cross-language requirements and ex
1313
- [Library Guidelines](specification/library-guidelines.md)
1414
- [Package/Library Layout](specification/library-layout.md)
1515
- API Specification
16-
- [CorrelationContext](specification/correlationcontext/api.md)
16+
- [Baggage](specification/baggage/api.md)
1717
- [Propagators](specification/context/api-propagators.md)
1818
- [Tracing](specification/trace/api.md)
1919
- [Metrics](specification/metrics/api.md)

specification/baggage/api.md

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Baggage API
2+
3+
<details>
4+
<summary>
5+
Table of Contents
6+
</summary>
7+
8+
- [Overview](#overview)
9+
- [Baggage](#baggage)
10+
- [Get baggages](#get-all)
11+
- [Get baggage](#get-baggage)
12+
- [Set baggage](#set-baggage)
13+
- [Remove baggage](#remove-baggage)
14+
- [Clear](#clear)
15+
- [Baggage Propagation](#baggage-propagation)
16+
- [Serialization](#serialization)
17+
- [Conflict Resolution](#conflict-resolution)
18+
19+
</details>
20+
21+
## Overview
22+
23+
The Baggage API consists of:
24+
25+
- the `Baggage`
26+
- functions to interact with the `Baggage` in a `Context`
27+
28+
### Baggage
29+
30+
`Baggage` is used to annotate telemetry, adding context and information to metrics, traces, and logs.
31+
It is an abstract data type represented by a set of name/value pairs describing user-defined properties.
32+
Each name in `Baggage` MUST be associated with exactly one value.
33+
34+
### Get all
35+
36+
Returns the name/value pairs in the `Baggage`. The order of name/value pairs MUST NOT be
37+
significant. Based on the language specification, the returned value can be
38+
either an immutable collection or an immutable iterator to the collection of
39+
name/value pairs in the `Baggage`.
40+
41+
OPTIONAL parameters:
42+
43+
`Context` the context containing the `Baggage` from which to get the baggages.
44+
45+
### Get baggage
46+
47+
To access the value for a name/value pair by a prior event, the Baggage API
48+
SHALL provide a function that takes a context and a name as input, and returns a
49+
value. Returns the value associated with the given name, or null
50+
if the given name is not present.
51+
52+
REQUIRED parameters:
53+
54+
`Name` the name to return the value for.
55+
56+
OPTIONAL parameters:
57+
58+
`Context` the context containing the `Baggage` from which to get the baggage entry.
59+
60+
### Set baggage
61+
62+
To record the value for a name/value pair, the Baggage API SHALL provide a function which
63+
takes a context, a name, and a value as input. Returns a new `Context` which
64+
contains a `Baggage` with the new value.
65+
66+
REQUIRED parameters:
67+
68+
`Name` the name for which to set the value.
69+
70+
`Value` the value to set.
71+
72+
OPTIONAL parameters:
73+
74+
`Context` the context containing the `Baggage` in which to set the baggage entry.
75+
76+
### Remove baggage
77+
78+
To delete a name/value pair, the Baggage API SHALL provide a function which takes a context
79+
and a name as input. Returns a new `Context` which no longer contains the selected name.
80+
81+
REQUIRED parameters:
82+
83+
`Name` the name to remove.
84+
85+
OPTIONAL parameters:
86+
87+
`Context` the context containing the `Baggage` from which to remove the baggage entry.
88+
89+
### Clear
90+
91+
To avoid sending any name/value pairs to an untrusted process, the Baggage API SHALL provide
92+
a function to remove all baggage entries from a context. Returns a new `Context`
93+
with no `Baggage`.
94+
95+
OPTIONAL parameters:
96+
97+
`Context` the context containing the `Baggage` from which to remove all baggage entries.
98+
99+
## Baggage Propagation
100+
101+
`Baggage` MAY be propagated across process boundaries or across any arbitrary boundaries
102+
(process, $OTHER_BOUNDARY1, $OTHER_BOUNDARY2, etc) for various reasons.
103+
104+
### Serialization
105+
106+
Until the [W3C Baggage](https://w3c.github.io/baggage/) specification is recommended for use, OpenTelemetry `Baggage` implementations MUST be serialized according to the [editor's draft of W3C Correlation Context as of March 27, 2020](https://github.com/w3c/correlation-context/blob/c974664b9ab4d33af6355f1f7f03a2d52c89a99e/correlation_context/HTTP_HEADER_FORMAT.md) using a vendor-specific header name to avoid collisions with the W3C Baggage specification should it change in the future.
107+
108+
#### Header Name
109+
110+
`Baggage` implementations MUST use the header name `otcorrelations`.
111+
112+
#### Header Value
113+
114+
`Baggage` MUST be serialized according to the [editor's draft of W3C Correlation Context as of March 27, 2020](https://github.com/w3c/correlation-context/blob/c974664b9ab4d33af6355f1f7f03a2d52c89a99e/correlation_context/HTTP_HEADER_FORMAT.md).
115+
116+
`Baggage` values MUST be serialized as Percent-Encoded UTF-8 strings according to [RFC 3986 Section 2.1](https://tools.ietf.org/html/rfc3986#section-2.1).
117+
118+
#### Example
119+
120+
Baggage:
121+
122+
```json
123+
{
124+
"user": "foo@example.com",
125+
"name": "Example Name"
126+
}
127+
```
128+
129+
Header:
130+
131+
```
132+
otbaggages: user=foo%40example.com,name=Example%20Name
133+
```
134+
135+
## Conflict Resolution
136+
137+
If a new name/value pair is added and its name is the same as an existing name, than the new pair MUST take precedence. The value
138+
is replaced with the added value (regardless if it is locally generated or received from a remote peer).

specification/context/api-propagators.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Each concern creates a set of `Propagator`s for every supported
3535
`Propagator` type.
3636

3737
`Propagator`s leverage the `Context` to inject and extract data for each
38-
cross-cutting concern, such as traces and correlation context.
38+
cross-cutting concern, such as traces and `Baggage`.
3939

4040
Propagation is usually implemented via a cooperation of library-specific request
4141
interceptors and `Propagators`, where the interceptors detect incoming and outgoing requests and use the `Propagator`'s extract and inject operations respectively.
@@ -76,7 +76,7 @@ Injects the value into a carrier. For example, into the headers of an HTTP reque
7676
Required arguments:
7777

7878
- A `Context`. The Propagator MUST retrieve the appropriate value from the `Context` first, such as
79-
`SpanContext`, `CorrelationContext` or another cross-cutting concern context.
79+
`SpanContext`, `Baggage` or another cross-cutting concern context.
8080
- The carrier that holds the propagation fields. For example, an outgoing message or HTTP request.
8181

8282
#### Extract
@@ -94,7 +94,7 @@ Required arguments:
9494

9595
Returns a new `Context` derived from the `Context` passed as argument,
9696
containing the extracted value, which can be a `SpanContext`,
97-
`CorrelationContext` or another cross-cutting concern context.
97+
`Baggage` or another cross-cutting concern context.
9898

9999
## TextMap Propagator
100100

@@ -271,8 +271,8 @@ Implementations MAY provide global `Propagator`s for
271271
each supported `Propagator` type.
272272

273273
If offered, the global `Propagator`s should default to a composite `Propagator`
274-
containing the W3C Trace Context Propagator and the Correlation Context `Propagator`
275-
specified in [api-correlationcontext.md](../correlationcontext/api.md#serialization),
274+
containing the W3C Trace Context Propagator and the Baggage `Propagator`
275+
specified in [api-baggage.md](../baggage/api.md#serialization),
276276
in order to provide propagation even in the presence of no-op
277277
OpenTelemetry implementations.
278278

specification/context/context.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ or implicit.
3636
Users writing instrumentation in languages that use `Context` implicitly are
3737
discouraged from using the `Context` API directly. In those cases, users will
3838
manipulate `Context` through cross-cutting concerns APIs instead, in order to
39-
perform operations such as setting trace or correlation context values for
40-
a specified `Context`.
39+
perform operations such as setting trace or baggage entries for a specified
40+
`Context`.
4141

4242
A `Context` is expected to have the following operations, with their
4343
respective language differences:

specification/correlationcontext/api.md

-138
This file was deleted.

specification/glossary.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Some other fundamental terms are documented in the [overview document](overview.
3737
3838
In OpenTelemetry we refer to **in-band data** as data that is passed
3939
between components of a distributed system as part of business messages,
40-
for example, when trace or correlation contexts are included
40+
for example, when trace or baggages are included
4141
in the HTTP requests in the form of HTTP headers.
4242
Such data usually does not contain the telemetry,
4343
but is used to correlate and join the telemetry produced by various components.

specification/library-layout.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ api
1717
├── metrics
1818
├── trace
1919
│ └── propagation
20-
├── correlationcontext
20+
├── baggage
2121
│ └── propagation
2222
├── internal
2323
└── logs
@@ -33,9 +33,9 @@ This directory describes the API that provides in-process context propagation.
3333

3434
This directory describes the Metrics API that can be used to record application metrics.
3535

36-
### [/correlationcontext](correlationcontext/api.md)
36+
### [/baggage](baggage/api.md)
3737

38-
This directory describes the CorrelationContext API that can be used to manage context propagation
38+
This directory describes the Baggage API that can be used to manage context propagation
3939
and metrics-related labeling.
4040

4141
### [/trace](trace/api.md)
@@ -66,7 +66,7 @@ sdk
6666
├── metrics
6767
├── resource
6868
├── trace
69-
├── correlationcontext
69+
├── baggage
7070
├── internal
7171
└── logs
7272
```
@@ -88,7 +88,7 @@ information about the entity for which stats or traces are recorded. For example
8888
by a Kubernetes container can be linked to a resource that specifies the cluster, namespace, pod,
8989
and container name.
9090

91-
### `/sdk/correlationcontext`
91+
### `/sdk/baggage`
9292

9393
### [/sdk/trace](trace/sdk.md)
9494

0 commit comments

Comments
 (0)