MCPcopy
hub / github.com/grafana/tempo / SpanIDAndKindToToken

Function SpanIDAndKindToToken

pkg/util/traceid.go:94–99  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
94func 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

Callers 8

ConsumeWithFinalMethod · 0.92
ConsumeWithFinalMethod · 0.92
ConsumeWithFinalMethod · 0.92
TestSpanIDAndKindToTokenFunction · 0.85

Calls 1

SpanIDToUint64Function · 0.85