Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAverage ¶
GetAverage retrieves or creates an average metric.
GetAverage operates like GetDuration and GetCounter, handling average metrics. It additionally requires a duration parameter for the new average metric.
Parameters: - name: string - The name of the average metric. - duration: time.Duration - The duration for the average calculation.
Returns: - *probe.Average: Pointer to the retrieved or newly created average metric.
func GetCounter ¶
GetCounter retrieves or creates a counter metric.
Similar to GetDuration, GetCounter looks for an existing counter metric or creates a new one if it doesn't exist, ensuring thread safety with mutex locks.
Parameters: - name: string - The name of the counter metric.
Returns: - *probe.Counter: Pointer to the retrieved or newly created counter metric.
func GetDuration ¶
GetDuration retrieves or creates a duration metric.
GetDuration first attempts to find an existing duration metric by its name. If it doesn't exist, a new one is created and added to the map. It ensures thread safety using mutex locks.
Parameters: - name: string - The name of the duration metric.
Returns: - *probe.Duration: Pointer to the retrieved or newly created duration metric.
Types ¶
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics structure holds various types of metrics like counters, durations, and averages.
Metrics provides a thread-safe way to create and manage different types of metric probes such as counters, durations, and averages. It uses sync.RWMutex to handle concurrent access.
func New ¶
func New() *Metrics
New creates and returns a new Metrics instance.
New initializes a Metrics instance with empty maps for counters, durations, and averages.
Returns: - *Metrics: Pointer to the newly created Metrics instance.
func (*Metrics) GetAverage ¶
GetAverage retrieves or creates an average metric.
GetAverage operates like GetDuration and GetCounter, handling average metrics. It additionally requires a duration parameter for the new average metric.
Parameters: - name: string - The name of the average metric. - duration: time.Duration - The duration for the average calculation.
Returns: - *probe.Average: Pointer to the retrieved or newly created average metric.
func (*Metrics) GetCounter ¶
GetCounter retrieves or creates a counter metric.
Similar to GetDuration, GetCounter looks for an existing counter metric or creates a new one if it doesn't exist, ensuring thread safety with mutex locks.
Parameters: - name: string - The name of the counter metric.
Returns: - *probe.Counter: Pointer to the retrieved or newly created counter metric.
func (*Metrics) GetDuration ¶
GetDuration retrieves or creates a duration metric.
GetDuration first attempts to find an existing duration metric by its name. If it doesn't exist, a new one is created and added to the map. It ensures thread safety using mutex locks.
Parameters: - name: string - The name of the duration metric.
Returns: - *probe.Duration: Pointer to the retrieved or newly created duration metric.