Skip to content

Commit 19a186f

Browse files
Fix the section on 64bit systems (#356)
* fix the section on 64bit systems * field ->value * added a comma * Update spec/60-trace-id-format.md Co-Authored-By: Yuri Shkuro <[email protected]> * Update spec/60-trace-id-format.md Co-Authored-By: Yuri Shkuro <[email protected]> * Update spec/60-trace-id-format.md Co-Authored-By: Yuri Shkuro <[email protected]> * Update spec/60-trace-id-format.md Co-Authored-By: Yuri Shkuro <[email protected]> * Update spec/60-trace-id-format.md Co-Authored-By: Yuri Shkuro <[email protected]> * Update spec/60-trace-id-format.md Co-Authored-By: Yuri Shkuro <[email protected]> * addressed feedback and added a note about tracestate * small change to improve readability * clarifications * took @yurishkuro suggestions
1 parent 162a5c9 commit 19a186f

File tree

1 file changed

+73
-18
lines changed

1 file changed

+73
-18
lines changed

spec/60-trace-id-format.md

Lines changed: 73 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,75 @@
11
## Considerations for trace-id field generation
22

3-
A vendor SHOULD generate globally unique values for `trace-id`. Many unique
4-
identification generation algorithms create IDs where one part of the value is
5-
constant (often time- or host-based), and the other part is a randomly generated
6-
value. Because tracing systems may make sampling decisions based on the value of
7-
`trace-id`, for increased interoperability vendors MUST keep the random part of
8-
`trace-id` ID on the left side.
9-
10-
When a system operates with a `trace-id` that is shorter than 16 bytes, it
11-
SHOULD fill-in the extra bytes with random values rather than zeroes. Let's say
12-
the system works with an 8-byte `trace-id` like `3ce929d0e0e4736`. Instead of
13-
setting `trace-id` value to `0000000000000003ce929d0e0e4736` it SHOULD generate
14-
a value like `4bf92f3577b34da6a3ce929d0e0e4736` where `4bf92f3577b34da6a` is a
15-
random value or a function of time and host value.
16-
17-
**Note**: Even though a system may operate with a shorter `trace-id` for
18-
[distributed trace](https://w3c.github.io/trace-context/#dfn-distributed-traces)
19-
reporting, the full `trace-id` MUST be propagated to conform to the
20-
specification.
3+
This section suggests some best practices to consider when platform or tracing
4+
vendor implement `trace-id` generation and propagation algorithms. These
5+
practices will ensure better interoperability of different systems.
6+
7+
### Uniqueness of `trace-id`
8+
9+
The value of `trace-id` SHOULD be globally unique. This field is typically used
10+
for unique identification of a <a>distributed trace</a>. It is common for
11+
<a>distributed traces</a> to span various components, including, for example,
12+
cloud services. Cloud services tend to serve variety of clients and have a very
13+
high throughput of requests. So global uniqueness of `trace-id` is important,
14+
even when local uniqueness might seem like a good solution.
15+
16+
### Randomness of `trace-id`
17+
18+
Randomly generated value of `trace-id` SHOULD be preferred over other
19+
algorithms of generating a globally unique identifiers. Randomness of `trace-id`
20+
addresses some [security](#security-considerations) and [privacy
21+
concerns](#privacy-considerations) of exposing unwanted information. Randomness
22+
also allows tracing vendors to base sampling decisions on `trace-id` field value
23+
and avoid propagating an additional sampling context.
24+
25+
As shown in the next section, it is important for `trace-id` to carry
26+
"uniqueness" and "randomness" in the right part of the `trace-id`, for better
27+
inter-operability with some existing systems.
28+
29+
### Handling `trace-id` for complaint platforms with shorter internal identifiers
30+
31+
There are tracing systems which use a `trace-id` that is shorter than 16 bytes,
32+
which are still willing to adopt this specification.
33+
34+
If such a system is capable of propagating a fully compliant `trace-id`, even
35+
while still requiring a shorter, non-complaint identifier for internal purposes,
36+
the system is encouraged to utilize the `tracestate` header to propagate the
37+
additional internal identifier. However, if a system would instead prefer to use
38+
the internal identifier as the basis for a fully complaint `trace-id`, it SHOULD
39+
be incorporated at the as rightmost part of a `trace-id`. For example, tracing
40+
system may receive `234a5bcd543ef3fa53ce929d0e0e4736` as a `trace-id`, hovewer
41+
internally it will use `53ce929d0e0e4736` as an identifier.
42+
43+
### Interoperating with existing systems which use shorter identifiers
44+
45+
There are tracing systems which are not capable of propagating the entire 16
46+
bytes of a `trace-id`. For better interoperability between a fully compliant
47+
systems with these existing systems, the following practices are recommended:
48+
49+
1. When a system creates an outbound message and needs to generate a fully
50+
compliant 16 bytes `trace-id` from a shorter identifier, it SHOULD left pad
51+
the original identifier with zeroes. For example, the identifier
52+
`53ce929d0e0e4736`, SHOULD be converted to `trace-id` value
53+
`000000000000000053ce929d0e0e4736`.
54+
2. When a system receives an inbound message and needs to convert the 16 bytes
55+
`trace-id` to a shorter identifier, the rightmost part of `trace-id` SHOULD
56+
be used as this identifier. For instance, if the the value of `trace-id` was
57+
`234a5bcd543ef3fa53ce929d0e0e4736` on an incoming request, tracing system
58+
SHOULD use identifier with the value of `53ce929d0e0e4736`.
59+
60+
Similar transformations are expected when tracing system converts other
61+
distributed trace context propagation formats to W3C Trace Context. Shorter
62+
identifiers SHOULD be left padded with zeros when converted to 16 bytes
63+
`trace-id` and rightmost part of `trace-id` SHOULD be used as a shorter
64+
identifier.
65+
66+
Note, many existing systems that are not capable of propagating the whole
67+
`trace-id` will not propagate `tracestate` header either. However, such system
68+
can still use `tracestate` header to propagate additional data that is known by
69+
this system. For example, some systems use two flags indicating whether
70+
distributed trace needs to be recorded or not. In this case one flag can be send
71+
as `sampled` flag of `traceparent` header and `tracestate` can be used to send
72+
and receive an additional flag. Compliant systems will propagate this flag along
73+
all other key/value pairs. Existing systems which are not capable of
74+
`tracestate` propagation will truncate all additional values from `tracestate`
75+
and only pass along that flag.

0 commit comments

Comments
 (0)