Documentation
¶
Overview ¶
Package diagnostics lets a plugin publish a small, bounded set of in-process measurements. The host pulls them through the PluginLifecycle GetDiagnostics RPC and merges them into its own diagnostics collector.
The package is deliberately narrow so a plugin cannot leak data or flood the host: attribute keys are a closed enum, attribute values and metric names are pattern-checked, and the number of metrics, series per metric and attributes per series is capped. Observations that break a rule are dropped (never clamped) and flag the next snapshot as truncated. Never record resource names, queries, identifiers, error text or credentials as attribute values.
Index ¶
- Constants
- Variables
- func ValidKey(key Key) bool
- func ValidName(name string) bool
- func ValidUnit(unit string) bool
- func ValidValue(value string) bool
- type Attr
- type Counter
- type Gauge
- type Histogram
- type Key
- type Registry
- func (r *Registry) Counter(name, unit string) (*Counter, error)
- func (r *Registry) Gauge(name, unit string) (*Gauge, error)
- func (r *Registry) Histogram(name, unit string, bounds []float64) (*Histogram, error)
- func (r *Registry) Snapshot() ([]*lifecyclepb.DiagMetric, bool)
- func (r *Registry) StartUnixNano() int64
Constants ¶
const ( SchemaVersion = 1 MaxMetrics = 24 MaxPoints = 16 MaxAttrs = 4 MaxBounds = 16 )
Wire limits. Hosts enforce the same limits and drop nonconforming data.
const ( KeyOperation = lifecyclepb.DiagKey_DIAG_KEY_OPERATION KeyOutcome = lifecyclepb.DiagKey_DIAG_KEY_OUTCOME KeyPhase = lifecyclepb.DiagKey_DIAG_KEY_PHASE KeyState = lifecyclepb.DiagKey_DIAG_KEY_STATE KeyReason = lifecyclepb.DiagKey_DIAG_KEY_REASON KeyCache = lifecyclepb.DiagKey_DIAG_KEY_CACHE KeyQueue = lifecyclepb.DiagKey_DIAG_KEY_QUEUE KeyDirection = lifecyclepb.DiagKey_DIAG_KEY_DIRECTION KeyEvent = lifecyclepb.DiagKey_DIAG_KEY_EVENT )
Allowed attribute keys.
Variables ¶
var ( // ErrInvalidMetric means a name, unit or bucket layout was rejected. ErrInvalidMetric = errors.New("invalid diagnostics metric") // ErrTooManyMetrics means the registry already holds MaxMetrics metrics. ErrTooManyMetrics = errors.New("too many diagnostics metrics") )
Functions ¶
func ValidValue ¶
ValidValue reports whether value is an allowed attribute value.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a monotonically increasing total. A nil Counter ignores calls.
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge is a current value. A nil Gauge ignores calls.
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
Histogram is a cumulative distribution. A nil Histogram ignores calls.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds a plugin's instruments. Use Default for the process registry.
func Default ¶
func Default() *Registry
Default returns the process-wide registry served by the SDK lifecycle service.
func (*Registry) Histogram ¶
Histogram registers or returns a histogram with 1..MaxBounds increasing bounds.
func (*Registry) Snapshot ¶
func (r *Registry) Snapshot() ([]*lifecyclepb.DiagMetric, bool)
Snapshot copies current state. Metrics without points are omitted, so an unobserved instrument is absent rather than reported as zero. It is safe for concurrent use and holds each instrument lock only while copying.
func (*Registry) StartUnixNano ¶
StartUnixNano is when this registry was created; it changes on restart.