Documentation
¶
Index ¶
- Variables
- func EqualHexStringTraceIDs(a, b string) (bool, error)
- func HexStringToSpanID(id string) ([]byte, error)
- func HexStringToTraceID(id string) ([]byte, error)
- func NewTokenHasher() hash.Hash64
- func PadTraceIDString(id string) string
- func PadTraceIDTo16Bytes(traceID []byte) []byte
- func SpanIDAndKindToToken(id []byte, kind int) uint64
- func SpanIDToHexString(byteID []byte) string
- func SpanIDToUint64(id []byte) uint64
- func StatusText(code int) string
- func TokenForID(h hash.Hash64, buffer []byte, kind int32, id []byte) uint64
- func TraceIDToHexString(byteID []byte) string
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTraceNotFound can be used when we don't find a trace ErrTraceNotFound = errors.New("trace not found") // StatusClientClosedRequest is the status code for when a client request cancellation of an http request StatusClientClosedRequest = 499 StatusTextClientClosedRequest = "Request Cancelled" ErrUnsupported = fmt.Errorf("unsupported") )
Functions ¶
func EqualHexStringTraceIDs ¶
EqualHexStringTraceIDs compares two trace ID strings and compares the resulting bytes after padding. Returns true unless there is a reason not to.
func HexStringToSpanID ¶
func HexStringToTraceID ¶
func NewTokenHasher ¶
NewTokenHasher returns a new hash.Hash64 for use with TokenForID.
func PadTraceIDString ¶
PadTraceIDString left-pads a trace ID hex string to 32 characters with zeros. This produces W3C/OpenTelemetry compliant 32-character lowercase hex trace IDs.
func PadTraceIDTo16Bytes ¶
func SpanIDAndKindToToken ¶
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 take the span kind into account.
func SpanIDToHexString ¶
SpanIDToHexString converts a span ID to its string representation and WITHOUT removing any leading zeros. If the id is < 16, left pad with 0s
func SpanIDToUint64 ¶
SpanIDToUint64 converts a span ID into an uint64 representation. This is useful when using a span ID as key in a map. If the ID is longer than 8 bytes, the bytes at larger positions are discarded. The function does not make any guarantees about the endianess or ordering of converted IDs.
Note: span IDs are not always unique within a trace (e.g. zipkin traces) SpanIDAndKindToToken could be more appropriate in some cases.
func StatusText ¶
func TokenForID ¶
TokenForID returns a token for use as a key in a hash map given a span ID and span kind. h and buffer (must be at least 4 bytes) are provided by the caller for reuse across calls to avoid repeated allocations. Use NewTokenHasher to create h. kind is included because in zipkin traces the span id is shared between client and server spans.
func TraceIDToHexString ¶
TraceIDToHexString converts a trace ID to its string representation and removes any leading zeros.
Types ¶
This section is empty.