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

Add a section for OTel specific values in TraceState. #1852

Merged
merged 30 commits into from
Oct 15, 2021
Merged
Changes from 19 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e3479a6
Add a section for OTel specific values in TraceState.
carlosalberto Aug 5, 2021
00cb453
Update specification/trace/api.md
carlosalberto Aug 5, 2021
59c30d1
Update specification/trace/api.md
carlosalberto Aug 5, 2021
a9edb5f
Fix sample.
carlosalberto Aug 5, 2021
aa51b8e
Merge branch 'main' into trace_state_otel_values
carlosalberto Aug 11, 2021
ba7b543
Apply feedback.
carlosalberto Aug 11, 2021
885c99a
Use same notation as TraceContext.
carlosalberto Aug 19, 2021
223c5cf
Remove unused OWS mention.
carlosalberto Aug 19, 2021
e067da0
Fix link.
carlosalberto Aug 19, 2021
0fb7420
Merge branch 'main' into trace_state_otel_values
carlosalberto Aug 26, 2021
bc36949
Update specification/trace/sdk.md
carlosalberto Aug 26, 2021
7a839f7
Clarify values.
carlosalberto Aug 26, 2021
85e9a9c
Prevent larger than 256 char values.
carlosalberto Aug 26, 2021
b8dc7bd
Fix typo.
carlosalberto Aug 26, 2021
3e7bf62
Update specification/trace/sdk.md
carlosalberto Aug 26, 2021
24c1dd6
Merge branch 'main' into trace_state_otel_values
carlosalberto Sep 1, 2021
47fde3f
Move trace state handling to its own document.
carlosalberto Sep 2, 2021
75f01b1
Update specification/trace/tracestate-handling.md
carlosalberto Sep 2, 2021
e1a1298
Fix lint.
carlosalberto Sep 2, 2021
7ac0e3c
Apply feedback.
carlosalberto Sep 15, 2021
7254826
Fix typo.
carlosalberto Sep 15, 2021
cfafa77
s/SHOULD/MUST
carlosalberto Sep 15, 2021
238fe23
Merge branch 'main' into trace_state_otel_values
carlosalberto Sep 15, 2021
f16c34c
Merge branch 'main' into trace_state_otel_values
carlosalberto Sep 20, 2021
e84f79c
Merge branch 'main' into trace_state_otel_values
carlosalberto Sep 29, 2021
845ddec
Merge branch 'main' into trace_state_otel_values
carlosalberto Oct 4, 2021
287bd68
Update specification/trace/tracestate-handling.md
carlosalberto Oct 14, 2021
3e8fb99
Merge branch 'main' into trace_state_otel_values
carlosalberto Oct 14, 2021
92c01c2
Merge branch 'main' into trace_state_otel_values
carlosalberto Oct 15, 2021
a04d104
Merge branch 'main' into trace_state_otel_values
jmacd Oct 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
73 changes: 73 additions & 0 deletions specification/trace/tracestate-handling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# TraceState Handling
carlosalberto marked this conversation as resolved.
Show resolved Hide resolved

**Status**: [Experimental](../document-status.md)

In alignment to the [TraceContext](https://www.w3.org/TR/trace-context/) specification, this section uses the
Augmented Backus-Naur Form (ABNF) notation of [RFC5234](https://www.w3.org/TR/trace-context/#bib-rfc5234),
including the DIGIT rule in that document.

When setting [TraceState](api.md#tracestate) values that are part of the OTel ecosystem,
they MUST all be contained in a single entry using the `ot` key, with the value being
jmacd marked this conversation as resolved.
Show resolved Hide resolved
a semicolon separated list of key-value pairs such as:

* `ot=p:8;r:64`
* `ot=foo:bar;k1:13`
jmacd marked this conversation as resolved.
Show resolved Hide resolved

carlosalberto marked this conversation as resolved.
Show resolved Hide resolved
The list can be formally defined as:

```
list = list-member *( ";" list-member )
list-member = key ":" value
jmacd marked this conversation as resolved.
Show resolved Hide resolved
```

The complete list length MUST NOT exceed 256 characters, as defined by the
[TraceState value section](https://www.w3.org/TR/trace-context/#value),
and the used keys MUST be unique.
carlosalberto marked this conversation as resolved.
Show resolved Hide resolved

## Key

The key is an identifier that describes an OTel concern.
Simple examples are `p`, `ts`, or `s1`.

The key can be formally defined as:

```
key = lcalpha *(lcalpha / DIGIT )
lcalpha = %x61-7A ; a-z
```

Specific keys used by OTel concerns MUST be defined as part as the Specification.

## Value

The value is an opaque string. Although it has no maximum allowed length,
it is recommended to use short values, as the **entire** list of key-values
MUST NOT exceed 256 characters.

The value can be formally defined as:

```
value = *(chr)
chr = ucalpha / lcalpha / DIGIT / "." / "_" / "-"
ucalpha = %x41-5A ; A-Z
lcalpha = %x61-7A ; a-z
```

## Setting values
carlosalberto marked this conversation as resolved.
Show resolved Hide resolved

Set values MUST be either updated or added to the `ot` entry in `TraceState`,
in order to preserve existing values belonging to other OTel concerns. For example,
if a given concern K wants to set `k1:13`:

* `ot=p:8;r:64` will become `ot=p:8;r:64;k1:13`.
* `ot=p:8,r:64;k1:7` will become `ot:p8;r:64;k1:13`.
carlosalberto marked this conversation as resolved.
Show resolved Hide resolved

If setting a value ends up making the entire `ot` entry exceed the 256 characters limit,
SDKs are advised to abort the operation and signal the user about the error, e.g.

```go
traceState, err := SetTraceStateValue(traceState, value)
if err != nil {
// Could not set the specified value, traceState was not updated.
}
```
carlosalberto marked this conversation as resolved.
Show resolved Hide resolved