trace

package
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 7 Imported by: 0

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

func (t *ID) New() string

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"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL