Documentation
¶
Overview ¶
Package use provides types for USE (Utilization, Saturation, Errors) metrics.
USE metrics are resource-oriented metrics defined by Brendan Gregg:
- Utilization: Percentage of time the resource is busy
- Saturation: Degree to which the resource has extra work it can't service (queue depth)
- Errors: Count of error events
These map to the Saturation Golden Signal.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
type Attribute struct {
// Key is the attribute key.
Key string `json:"key"`
// Description explains the attribute.
Description string `json:"description,omitempty"`
// Required indicates the attribute must be present.
Required bool `json:"required,omitempty"`
}
Attribute defines a metric attribute.
type Definition ¶
type Definition struct {
// Resource is the resource being measured.
Resource ResourceType `json:"resource"`
// Name is the metric name prefix.
Name string `json:"name"`
// Description explains what this measures.
Description string `json:"description,omitempty"`
// Utilization metric configuration.
Utilization *UtilizationConfig `json:"utilization,omitempty"`
// Saturation metric configuration.
Saturation *SaturationConfig `json:"saturation,omitempty"`
// Errors metric configuration.
Errors *ErrorsConfig `json:"errors,omitempty"`
// Attributes are common attributes.
Attributes []Attribute `json:"attributes,omitempty"`
}
Definition describes USE metrics for a resource.
func CPUDefinition ¶
func CPUDefinition() Definition
CPUDefinition returns a standard USE definition for CPU.
func ConnectionPoolDefinition ¶
func ConnectionPoolDefinition(poolName string) Definition
ConnectionPoolDefinition returns a USE definition for a connection pool.
func GoroutineDefinition ¶
func GoroutineDefinition() Definition
GoroutineDefinition returns a USE definition for goroutines.
func MemoryDefinition ¶
func MemoryDefinition() Definition
MemoryDefinition returns a standard USE definition for memory.
func QueueDefinition ¶
func QueueDefinition(queueName string) Definition
QueueDefinition returns a USE definition for a named queue.
type ErrorsConfig ¶
type ErrorsConfig struct {
// Metric is the OTel metric name.
Metric string `json:"metric"`
// Unit is typically count.
Unit string `json:"unit,omitempty"`
}
ErrorsConfig configures resource error metrics.
type MetricType ¶
type MetricType string
MetricType identifies a USE metric category.
const ( // MetricUtilization represents resource utilization. MetricUtilization MetricType = "utilization" // MetricSaturation represents resource saturation. MetricSaturation MetricType = "saturation" // MetricErrors represents resource errors. MetricErrors MetricType = "errors" )
type Observation ¶
type Observation struct {
// Resource identifies the resource type.
Resource ResourceType
// Utilization as a ratio 0.0-1.0.
Utilization float64
// Saturation as queue depth or count.
Saturation float64
// ErrorCount number of errors.
ErrorCount int64
// Attributes for this observation.
Attributes map[string]string
}
Observation captures a single USE observation.
type ResourceType ¶
type ResourceType string
ResourceType identifies the type of resource being measured.
const ( // ResourceCPU represents CPU resources. ResourceCPU ResourceType = "cpu" // ResourceMemory represents memory resources. ResourceMemory ResourceType = "memory" // ResourceDisk represents disk resources. ResourceDisk ResourceType = "disk" // ResourceNetwork represents network resources. ResourceNetwork ResourceType = "network" // ResourceQueue represents queue resources. ResourceQueue ResourceType = "queue" // ResourcePool represents connection pool resources. ResourcePool ResourceType = "pool" // ResourceThread represents thread pool resources. ResourceThread ResourceType = "thread" // ResourceGoroutine represents goroutine resources. ResourceGoroutine ResourceType = "goroutine" )
type SaturationConfig ¶
type SaturationConfig struct {
// Metric is the OTel metric name.
Metric string `json:"metric"`
// Unit is typically count or items.
Unit string `json:"unit,omitempty"`
// GoldenSignal maps to "saturation".
GoldenSignal string `json:"golden_signal,omitempty"`
}
SaturationConfig configures saturation metrics.
type UtilizationConfig ¶
type UtilizationConfig struct {
// Metric is the OTel metric name.
Metric string `json:"metric"`
// Unit is typically "1" for ratio or "%" for percentage.
Unit string `json:"unit,omitempty"`
// GoldenSignal maps to "saturation".
GoldenSignal string `json:"golden_signal,omitempty"`
}
UtilizationConfig configures utilization metrics.