Skip to content

Commit

Permalink
fix: ensure random part of trace id is uniformly distributed (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan committed Feb 13, 2024
1 parent 4f707ec commit b4d1bc7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion spec/20-http_request_header_format.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ There are two additional options that vendors MAY follow:
The second least significant bit of the trace-flags field denotes the `random-trace-id` flag.

When starting or restarting a trace (that is, when the participant generates a new `trace-id`), the following rules apply:
* If that flag is set, at least the right-most 7 bytes of the `trace-id` MUST be selected randomly (or pseudo-randomly) from a uniform distribution of all `2^56` possible values.
* If that flag is set, at least the right-most 7 bytes of the `trace-id` MUST be selected randomly (or pseudo-randomly) with uniform distribution over the interval [0..2^56-1].
* If the flag is not set, the `trace-id` MAY still be randomly (or pseudo-randomly) generated.
* When unset, the `trace-id` MAY be generated in any way that satisfies the requirements of the [trace ID format](#trace-id).
* When at least the right-most 7 bytes of the `trace-id` are randomly (or pseudo-randomly) generated, the `random-trace-id` flag SHOULD be set to `1`.
Expand Down
4 changes: 2 additions & 2 deletions spec/60-trace-id-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ also allows tracing vendors to base sampling decisions on `trace-id` field value
and avoid propagating an additional sampling context.

If the `random-trace-id` flag is set, at least the right-most 7 bytes of the
`trace-id` MUST be selected randomly (or pseudo-randomly) from a uniform
distribution of all `2^56` possible values.
`trace-id` MUST be selected randomly (or pseudo-randomly) with uniform distribution
over the interval [0..2^56-1].

As shown in the next section, if part of the `trace-id` is nonrandom,
it is important for the random part of the `trace-id` to be as far right in the
Expand Down

0 comments on commit b4d1bc7

Please sign in to comment.