Documentation ¶
Overview ¶
Package trace provides functionality for generating unique trace identifiers. It is designed to be used in distributed systems for tracking requests or operations across multiple services or components.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
ID represents a structure for generating unique identifiers. It uses a combination of hostname, timestamp, and a sequence number to ensure uniqueness across distributed systems.
func NewTraceID ¶
func NewTraceID() *ID
NewTraceID creates and returns a new ID instance. It initializes the ID with the current hostname and timestamp.
Returns:
- *ID: A pointer to the newly created ID instance.
Example:
traceID := NewTraceID() uniqueIdentifier := traceID.New()
func (*ID) New ¶
New generates and returns a new unique identifier.
Returns:
- string: A unique identifier combining the prefix and a sequence number.
Example:
traceID := NewTraceID() id1 := traceID.New() // e.g., "hostname-timestamp-sequence1" id2 := traceID.New() // e.g., "hostname-timestamp-sequence2"
Click to show internal directories.
Click to hide internal directories.