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)
| 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 |
| 45 | func 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 | |
| 56 | func HexStringToSpanID(id string) ([]byte, error) { |
| 57 | id = strings.TrimLeft(id, "0") |