Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename CorrelationContext to Baggage #857

Merged
merged 6 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The OpenTelemetry specification describes the cross-language requirements and ex
- [Library Guidelines](specification/library-guidelines.md)
- [Package/Library Layout](specification/library-layout.md)
- API Specification
- [CorrelationContext](specification/correlationcontext/api.md)
- [Baggage](specification/baggage/api.md)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- [Propagators](specification/context/api-propagators.md)
- [Tracing](specification/trace/api.md)
- [Metrics](specification/metrics/api.md)
Expand Down
138 changes: 138 additions & 0 deletions specification/baggage/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Baggage API
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any thoughts on naming this BaggageContext?
cc: @CodeBlanch


<details>
<summary>
Table of Contents
</summary>

- [Overview](#overview)
- [Baggage](#baggage)
- [Get baggages](#get-all)
- [Get baggage](#get-baggage)
- [Set baggage](#set-baggage)
- [Remove baggage](#remove-baggage)
- [Clear](#clear)
- [Baggage Propagation](#baggage-propagation)
- [Serialization](#serialization)
- [Conflict Resolution](#conflict-resolution)

</details>

## Overview

The Baggage API consists of:

- the `Baggage`
- functions to interact with the `Baggage` in a `Context`

### Baggage

`Baggage` is used to annotate telemetry, adding context and information to metrics, traces, and logs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not part of name change, but a question about Baggage - Does all the Baggage entries becomes part of Span attributes automatically? Or user has to write SpanProcessor to read Baggage, then populate it into Span.Attributes?

It is an abstract data type represented by a set of name/value pairs describing user-defined properties.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I went with a string in the .NET library because we lose all typing info propagating as W3C Baggage.

Each name in `Baggage` MUST be associated with exactly one value.

### Get all

Returns the name/value pairs in the `Baggage`. The order of name/value pairs MUST NOT be
significant. Based on the language specification, the returned value can be
either an immutable collection or an immutable iterator to the collection of
name/value pairs in the `Baggage`.

OPTIONAL parameters:

`Context` the context containing the `Baggage` from which to get the baggages.

### Get baggage
Copy link
Member

@CodeBlanch CodeBlanch Aug 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just happen to be working on this in the .NET library right now. Here's some questions in case we get into something other than the name change.

  • What type of case sensitivity should we have for keys?

  • What should the behavior be when null is passed as name to GetBaggage/SetBaggage/RemoveBaggage? Throw error or return null/do nothing?

  • What happens if you SetBaggage('name', null)? Is null valid? Should that throw? Should null remove the item if it exists (like we do for tags)?


To access the value for a name/value pair by a prior event, the Baggage API
SHALL provide a function that takes a context and a name as input, and returns a
value. Returns the value associated with the given name, or null
if the given name is not present.

REQUIRED parameters:

`Name` the name to return the value for.

OPTIONAL parameters:

`Context` the context containing the `Baggage` from which to get the baggage entry.

### Set baggage

To record the value for a name/value pair, the Baggage API SHALL provide a function which
takes a context, a name, and a value as input. Returns a new `Context` which
contains a `Baggage` with the new value.

REQUIRED parameters:

`Name` the name for which to set the value.

`Value` the value to set.

OPTIONAL parameters:

`Context` the context containing the `Baggage` in which to set the baggage entry.

### Remove baggage

To delete a name/value pair, the Baggage API SHALL provide a function which takes a context
and a name as input. Returns a new `Context` which no longer contains the selected name.

REQUIRED parameters:

`Name` the name to remove.

OPTIONAL parameters:

`Context` the context containing the `Baggage` from which to remove the baggage entry.

### Clear

To avoid sending any name/value pairs to an untrusted process, the Baggage API SHALL provide
a function to remove all baggage entries from a context. Returns a new `Context`
with no `Baggage`.

OPTIONAL parameters:

`Context` the context containing the `Baggage` from which to remove all baggage entries.

## Baggage Propagation

`Baggage` MAY be propagated across process boundaries or across any arbitrary boundaries
(process, $OTHER_BOUNDARY1, $OTHER_BOUNDARY2, etc) for various reasons.

### Serialization

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.

#### Header Name

`Baggage` implementations MUST use the header name `otcorrelations`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still the recommendation or we can now use Baggage?
#536 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's track it separately. I think we should keep the renaming PR small. @cijothomas can you file this issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cijothomas have you created an issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry i didn't hit submit:(
Thanks for creating the issue!


#### Header Value

`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).

`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).

#### Example

Baggage:

```json
{
"user": "[email protected]",
"name": "Example Name"
}
```

Header:

```
otbaggages: user=foo%40example.com,name=Example%20Name
```

## Conflict Resolution

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
is replaced with the added value (regardless if it is locally generated or received from a remote peer).
10 changes: 5 additions & 5 deletions specification/context/api-propagators.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Each concern creates a set of `Propagator`s for every supported
`Propagator` type.

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

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

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

#### Extract
Expand All @@ -93,7 +93,7 @@ Required arguments:

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

## TextMap Propagator

Expand Down Expand Up @@ -250,8 +250,8 @@ Implementations MAY provide global `Propagator`s for
each supported `Propagator` type.

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

Expand Down
4 changes: 2 additions & 2 deletions specification/context/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ or implicit.
Users writing instrumentation in languages that use `Context` implicitly are
discouraged from using the `Context` API directly. In those cases, users will
manipulate `Context` through cross-cutting concerns APIs instead, in order to
perform operations such as setting trace or correlation context values for
a specified `Context`.
perform operations such as setting trace or baggage entries for a specified
`Context`.

A `Context` is expected to have the following operations, with their
respective language differences:
Expand Down
138 changes: 0 additions & 138 deletions specification/correlationcontext/api.md

This file was deleted.

2 changes: 1 addition & 1 deletion specification/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Some other fundamental terms are documented in the [overview document](overview.

In OpenTelemetry we refer to **in-band data** as data that is passed
between components of a distributed system as part of business messages,
for example, when trace or correlation contexts are included
for example, when trace or baggages are included
in the HTTP requests in the form of HTTP headers.
Such data usually does not contain the telemetry,
but is used to correlate and join the telemetry produced by various components.
Expand Down
10 changes: 5 additions & 5 deletions specification/library-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ api
├── metrics
├── trace
│ └── propagation
├── correlationcontext
├── baggage
│ └── propagation
├── internal
└── logs
Expand All @@ -33,9 +33,9 @@ This directory describes the API that provides in-process context propagation.

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

### [/correlationcontext](correlationcontext/api.md)
### [/baggage](baggage/api.md)

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

### [/trace](trace/api.md)
Expand Down Expand Up @@ -66,7 +66,7 @@ sdk
├── metrics
├── resource
├── trace
├── correlationcontext
├── baggage
├── internal
└── logs
```
Expand All @@ -88,7 +88,7 @@ information about the entity for which stats or traces are recorded. For example
by a Kubernetes container can be linked to a resource that specifies the cluster, namespace, pod,
and container name.

### `/sdk/correlationcontext`
### `/sdk/baggage`

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

Expand Down
2 changes: 1 addition & 1 deletion specification/logs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Distributed tracing introduced the notion of request context propagation.

Fundamentally, though, nothing prevents the logs to adopt the same context
propagation concepts. If the recorded logs contained request context identifiers
(such as trace and span ids or user-defined correlation context) it would result
(such as trace and span ids or user-defined baggage) it would result
in much richer correlation between logs and traces, as well as correlation
between logs emitted by different components of a distributed system. This would
make logs significantly more valuable in distributed systems.
Expand Down
Loading