Skip to content

Commit

Permalink
Add description of TraceState operations (#905)
Browse files Browse the repository at this point in the history
* Add description of TraceState operations

* Apply suggestions from code review

Co-authored-by: Christian Neumüller <christian+github@neumueller.me>

* Apply suggestions from code review

Co-authored-by: Armin Ruech <armin.ruech@dynatrace.com>

* Add validation requirement

* Fix error handling

Co-authored-by: Christian Neumüller <christian+github@neumueller.me>
Co-authored-by: Armin Ruech <armin.ruech@dynatrace.com>
Co-authored-by: Sergey Kanzhelev <S.Kanzhelev@live.com>
  • Loading branch information
4 people committed Sep 3, 2020
1 parent 6b7b2ab commit 293a508
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
7 changes: 3 additions & 4 deletions specification/trace/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,10 @@ byte.
TraceFlags are present in all traces. The current version of the specification
only supports a single flag called [sampled](https://www.w3.org/TR/trace-context/#sampled-flag).

`TraceState` carries system-specific configuration data, represented as a list
`TraceState` carries vendor-specific trace identification data, represented as a list
of key-value pairs. TraceState allows multiple tracing
systems to participate in the same trace. Please review the [W3C
specification](https://www.w3.org/TR/trace-context/#tracestate-header) for
details on this field.
systems to participate in the same trace. It is fully described in the [W3C Trace Context
specification](https://www.w3.org/TR/trace-context/#tracestate-header).

### Retrieving the TraceId and SpanId

Expand Down
24 changes: 24 additions & 0 deletions specification/trace/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,30 @@ Thus, the SDK specification defines sets of possible requirements for
(for example, the `Span` could be one of the parameters passed to such a function,
or a getter could be provided).

## TraceState

`TraceState` is a part of [`SpanContext`](./api.md#spancontext), represented by an immutable list of string key/value pairs and
formally defined by the [W3C Trace Context specification](https://www.w3.org/TR/trace-context/#tracestate-header).
Tracing SDK MUST provide at least the following operations on `TraceState`:

* Get value for a given key
* Add a new key/value pair
* Update an existing value for a given key
* Delete a key/value pair

These operations MUST follow the rules described in the [W3C Trace Context specification](https://www.w3.org/TR/trace-context/#mutating-the-tracestate-field).
All mutating operations MUST return a new `TraceState` with the modifications applied.
`TraceState` MUST at all times be valid according to rules specified in [W3C Trace Context specification](https://www.w3.org/TR/trace-context/#tracestate-header-field-values).
Every mutating operations MUST validate input parameters.
If invalid value is passed the operation MUST NOT return `TraceState` containing invalid data
and MUST follow the [general error handling guidelines](../error-handling.md) (e.g. it usually must not return null or throw an exception).

Please note, since `SpanContext` is immutable, it is not possible to update `SpanContext` with a new `TraceState`.
Such changes then make sense only right before
[`SpanContext` propagation](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/context/api-propagators.md)
or [telemetry data exporting](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk.md#span-exporter).
In both cases, `Propagators` and `SpanExporters` may create a modified `TraceState` copy before serializing it to the wire.

## Span processor

Span processor is an interface which allows hooks for span start and end method
Expand Down

0 comments on commit 293a508

Please sign in to comment.