SpanIDAndKindToToken converts a span ID into a token for use as key in a hash map. The token is generated such that it has a low collision probability. In zipkin traces the span id is not guaranteed to be unique as it is shared between client and server spans. Therefore, it is sometimes required to
(id []byte, kind int)
| 92 | // that it has a low collision probability. In zipkin traces the span id is not guaranteed to be unique as it |
| 93 | // is shared between client and server spans. Therefore, it is sometimes required to take the span kind into account. |
| 94 | func SpanIDAndKindToToken(id []byte, kind int) uint64 { |
| 95 | if kind < 0 || kind >= len(spanKindFNVHashes) { |
| 96 | kind = 0 |
| 97 | } |
| 98 | return SpanIDToUint64(id) ^ spanKindFNVHashes[kind] |
| 99 | } |
| 100 | |
| 101 | // SpanIDToUint64 converts a span ID into an uint64 representation. This is useful when using a span ID as key |
| 102 | // in a map. If the ID is longer than 8 bytes, the bytes at larger positions are discarded. The function does |