Documentation
¶
Overview ¶
Package metrics provides OpenTelemetry-based observability for the SDK and allows developers to register custom metrics for their engrams and impulses.
Index ¶
- func Counter(name, description string) (metric.Int64Counter, error)
- func Gauge(name, description, unit string, callback func() float64) error
- func GetMeter() metric.Meter
- func Histogram(name, description, unit string) (metric.Float64Histogram, error)
- func RecordClientBufferAdded(ctx context.Context, reason string)
- func RecordClientBufferDrop(ctx context.Context, reason string)
- func RecordClientBufferFlush(ctx context.Context, count int)
- func RecordDehydrationSize(ctx context.Context, sizeBytes int64)
- func RecordHydrationSize(ctx context.Context, sizeBytes int64)
- func RecordK8sOperation(ctx context.Context, operation string, durationSec float64, success bool)
- func RecordStreamBackpressureTimeout(ctx context.Context, stage string)
- func RecordStreamMessage(ctx context.Context, direction string)
- func RecordStreamReconnectAttempt(ctx context.Context, reason string)
- func RecordStreamReconnectFailure(ctx context.Context, reason string)
- func RegisterClientBufferGauges(sizeFn func() float64, bytesFn func() float64) func()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Counter ¶
func Counter(name, description string) (metric.Int64Counter, error)
Counter creates a custom counter metric that developers can use in their engrams. Example:
counter, _ := metrics.Counter("myengram.records.processed_total", "Total records processed")
counter.Add(ctx, int64(len(records)))
func Gauge ¶
Gauge creates a custom gauge metric (async) that periodically calls the provided callback. Example:
metrics.Gauge("myengram.queue.size", "Current queue size", "items",
func() float64 { return float64(len(queue)) })
func GetMeter ¶
GetMeter returns the underlying OpenTelemetry meter for advanced use cases. Most developers should use Counter, Histogram, or Gauge instead.
func Histogram ¶
func Histogram(name, description, unit string) (metric.Float64Histogram, error)
Histogram creates a custom histogram metric for recording distributions. Example:
hist, _ := metrics.Histogram("myengram.processing.duration_seconds", "Processing duration", "s")
hist.Record(ctx, durationSec)
func RecordClientBufferAdded ¶
RecordClientBufferAdded increments add counter with a reason label.
func RecordClientBufferDrop ¶
RecordClientBufferDrop increments drop counter with a reason label.
func RecordClientBufferFlush ¶
RecordClientBufferFlush increments flush counter by count.
func RecordDehydrationSize ¶
RecordDehydrationSize records the size of dehydrated data for observability.
func RecordHydrationSize ¶
RecordHydrationSize records the size of hydrated data for observability.
func RecordK8sOperation ¶
RecordK8sOperation records the duration of a Kubernetes API operation.
func RecordStreamBackpressureTimeout ¶ added in v0.1.2
RecordStreamBackpressureTimeout records occurrences of backpressure timeouts. Stage should denote where the timeout happened (e.g., "client_receiver", "server_reader").
func RecordStreamMessage ¶
RecordStreamMessage increments the stream message counter. Direction should be "received" or "sent".
func RecordStreamReconnectAttempt ¶
RecordStreamReconnectAttempt increments the reconnect attempts counter with reason labeling.
func RecordStreamReconnectFailure ¶
RecordStreamReconnectFailure increments the reconnect failures counter (terminal) with reason labeling.
func RegisterClientBufferGauges ¶
RegisterClientBufferGauges registers async gauges for buffer size and bytes. The callbacks will be polled by the OTel SDK.
Types ¶
This section is empty.