Skip to content

Commit

Permalink
fix: ensure random part of trace id is uniformly distributed
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan committed Jan 30, 2024
1 parent bdbdbc7 commit 4f707ec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 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 random (or pseudo-random).
* 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 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
3 changes: 2 additions & 1 deletion spec/60-trace-id-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +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 randomly (or pseudo-randomly) generated.
`trace-id` MUST be selected randomly (or pseudo-randomly) from a uniform
distribution of all `2^56` possible values.

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 4f707ec

Please sign in to comment.