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

Function SpanIDToHexString

pkg/util/traceid.go:45–54  ·  view source on GitHub ↗

SpanIDToHexString converts a span ID to its string representation and WITHOUT removing any leading zeros. If the id is < 16, left pad with 0s

(byteID []byte)

Source from the content-addressed store, hash-verified

43// SpanIDToHexString converts a span ID to its string representation and WITHOUT removing any leading zeros.
44// If the id is < 16, left pad with 0s
45func SpanIDToHexString(byteID []byte) string {
46 dst := make([]byte, hex.EncodedLen(len(byteID)))
47 hex.Encode(dst, byteID)
48 // fast conversion to string
49 p := unsafe.SliceData(dst)
50 id := unsafe.String(p, len(dst))
51 // remove and pad
52 id = strings.TrimLeft(id, "0")
53 return fmt.Sprintf("%016s", id)
54}
55
56func HexStringToSpanID(id string) ([]byte, error) {
57 id = strings.TrimLeft(id, "0")

Callers 13

traceQLRunnerFunction · 0.92
KeepGroupMethod · 0.92
KeepGroupMethod · 0.92
KeepGroupMethod · 0.92
KeepGroupMethod · 0.92
CollectMethod · 0.92
KeepGroupMethod · 0.92
asTraceSearchMetadataFunction · 0.92

Calls 2

EncodeMethod · 0.65
StringMethod · 0.45