observability

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ObserveWithTimer

func ObserveWithTimer(histogram prometheus.Observer, timer *Timer)

ObserveWithTimer is a helper to observe a histogram with a timer

Types

type Metrics

type Metrics struct {
	// ENI operation metrics
	ENIOperationsTotal   *prometheus.CounterVec
	ENIOperationDuration *prometheus.HistogramVec
	ENIOperationErrors   *prometheus.CounterVec
	ENIAttachmentsTotal  prometheus.Gauge
	ENIDetachmentsTotal  prometheus.Gauge

	// Cleanup operation metrics
	CleanupOperationsTotal *prometheus.CounterVec
	CleanupDuration        *prometheus.HistogramVec
	CleanupErrors          *prometheus.CounterVec
	StaleCleanupsTotal     prometheus.Counter

	// Circuit breaker metrics
	CircuitBreakerState      *prometheus.GaugeVec
	CircuitBreakerOperations *prometheus.CounterVec

	// Coordination metrics
	ResourceLocks         prometheus.Gauge
	CoordinationConflicts prometheus.Counter
	CoordinationWaitTime  prometheus.Histogram

	// DPDK operation metrics
	DPDKOperationsTotal *prometheus.CounterVec
	DPDKRollbacksTotal  prometheus.Counter
	DPDKBindingErrors   *prometheus.CounterVec

	// AWS API metrics
	AWSAPICallsTotal    *prometheus.CounterVec
	AWSAPICallDuration  *prometheus.HistogramVec
	AWSAPIErrors        *prometheus.CounterVec
	AWSThrottlingEvents prometheus.Counter
}

Metrics holds all the Prometheus metrics for the controller

func NewMetrics

func NewMetrics() *Metrics

NewMetrics creates and registers all metrics (singleton pattern)

func (*Metrics) RecordAWSAPICall

func (m *Metrics) RecordAWSAPICall(service, operation, status string, duration time.Duration)

RecordAWSAPICall records metrics for an AWS API call

func (*Metrics) RecordAWSAPIError

func (m *Metrics) RecordAWSAPIError(service, operation, errorCategory string)

RecordAWSAPIError records an AWS API error

func (*Metrics) RecordAWSThrottling

func (m *Metrics) RecordAWSThrottling()

RecordAWSThrottling records an AWS throttling event

func (*Metrics) RecordCircuitBreakerOperation

func (m *Metrics) RecordCircuitBreakerOperation(operationType, result string)

RecordCircuitBreakerOperation records a circuit breaker operation

func (*Metrics) RecordCircuitBreakerState

func (m *Metrics) RecordCircuitBreakerState(operationType string, state int)

RecordCircuitBreakerState records the current state of a circuit breaker

func (*Metrics) RecordCleanupError

func (m *Metrics) RecordCleanupError(cleanupType, errorCategory string)

RecordCleanupError records a cleanup error

func (*Metrics) RecordCleanupOperation

func (m *Metrics) RecordCleanupOperation(cleanupType, status string, duration time.Duration)

RecordCleanupOperation records metrics for a cleanup operation

func (*Metrics) RecordCoordinationConflict

func (m *Metrics) RecordCoordinationConflict()

RecordCoordinationConflict records a coordination conflict

func (*Metrics) RecordCoordinationWaitTime

func (m *Metrics) RecordCoordinationWaitTime(duration time.Duration)

RecordCoordinationWaitTime records time spent waiting for coordination

func (*Metrics) RecordDPDKBindingError

func (m *Metrics) RecordDPDKBindingError(errorType, node string)

RecordDPDKBindingError records a DPDK binding error

func (*Metrics) RecordDPDKOperation

func (m *Metrics) RecordDPDKOperation(operation, status, node string)

RecordDPDKOperation records metrics for a DPDK operation

func (*Metrics) RecordDPDKRollback

func (m *Metrics) RecordDPDKRollback()

RecordDPDKRollback records a DPDK rollback

func (*Metrics) RecordENIError

func (m *Metrics) RecordENIError(operation, errorType, node string)

RecordENIError records an ENI operation error

func (*Metrics) RecordENIOperation

func (m *Metrics) RecordENIOperation(operation, status, node string, duration time.Duration)

RecordENIOperation records metrics for an ENI operation

func (*Metrics) RecordStaleCleanup

func (m *Metrics) RecordStaleCleanup()

RecordStaleCleanup records a stale resource cleanup

func (*Metrics) UpdateENIAttachments

func (m *Metrics) UpdateENIAttachments(count int)

UpdateENIAttachments updates the current number of ENI attachments

func (*Metrics) UpdateENIDetachments

func (m *Metrics) UpdateENIDetachments(count int)

UpdateENIDetachments updates the current number of ENI detachments

func (*Metrics) UpdateResourceLocks

func (m *Metrics) UpdateResourceLocks(count int)

UpdateResourceLocks updates the current number of resource locks

type OperationContext

type OperationContext struct {
	OperationID   string
	OperationType string
	NodeENI       string
	NodeID        string
	ENIID         string
	InstanceID    string
	StartTime     time.Time
	Metadata      map[string]interface{}
}

OperationContext holds context information for an operation

func NewOperationContext

func NewOperationContext(operationType string) *OperationContext

NewOperationContext creates a new operation context

func (*OperationContext) Duration

func (oc *OperationContext) Duration() time.Duration

Duration returns the elapsed time since the operation started

func (*OperationContext) LogFields

func (oc *OperationContext) LogFields() []interface{}

LogFields returns structured log fields for this context

func (*OperationContext) WithAttachment

func (oc *OperationContext) WithAttachment(attachment networkingv1alpha1.ENIAttachment) *OperationContext

WithAttachment adds attachment information to the context

func (*OperationContext) WithMetadata

func (oc *OperationContext) WithMetadata(key string, value interface{}) *OperationContext

WithMetadata adds metadata to the context

func (*OperationContext) WithNodeENI

func (oc *OperationContext) WithNodeENI(nodeENI *networkingv1alpha1.NodeENI) *OperationContext

WithNodeENI adds NodeENI information to the context

type StructuredLogger

type StructuredLogger struct {
	// contains filtered or unexported fields
}

StructuredLogger provides structured logging with consistent fields

func NewStructuredLogger

func NewStructuredLogger(logger logr.Logger, metrics *Metrics) *StructuredLogger

NewStructuredLogger creates a new structured logger

func (*StructuredLogger) LogAWSAPICall

func (sl *StructuredLogger) LogAWSAPICall(ctx context.Context, service, operation string, duration time.Duration, err error)

LogAWSAPICall logs an AWS API call with timing

func (*StructuredLogger) LogCircuitBreakerEvent

func (sl *StructuredLogger) LogCircuitBreakerEvent(ctx context.Context, operationType string, oldState, newState int, reason string)

LogCircuitBreakerEvent logs circuit breaker state changes

func (*StructuredLogger) LogCoordinationEvent

func (sl *StructuredLogger) LogCoordinationEvent(ctx context.Context, eventType string, resourceIDs []string, operationID string, details map[string]interface{})

LogCoordinationEvent logs coordination-related events

func (*StructuredLogger) LogDPDKRollback

func (sl *StructuredLogger) LogDPDKRollback(ctx context.Context, opCtx *OperationContext, reason string, rollbackSuccess bool)

LogDPDKRollback logs DPDK rollback events

func (*StructuredLogger) LogOperationError

func (sl *StructuredLogger) LogOperationError(ctx context.Context, opCtx *OperationContext, err error, message string)

LogOperationError logs an error during an operation

func (*StructuredLogger) LogOperationStart

func (sl *StructuredLogger) LogOperationStart(ctx context.Context, opCtx *OperationContext, message string)

LogOperationStart logs the start of an operation

func (*StructuredLogger) LogOperationSuccess

func (sl *StructuredLogger) LogOperationSuccess(ctx context.Context, opCtx *OperationContext, message string)

LogOperationSuccess logs successful completion of an operation

func (*StructuredLogger) LogOperationWarning

func (sl *StructuredLogger) LogOperationWarning(ctx context.Context, opCtx *OperationContext, message string)

LogOperationWarning logs a warning during an operation

func (*StructuredLogger) LogResourceMetrics

func (sl *StructuredLogger) LogResourceMetrics(ctx context.Context, attachmentCount, detachmentCount, lockCount int)

LogResourceMetrics logs current resource metrics

func (*StructuredLogger) LogStaleResourceDetection

func (sl *StructuredLogger) LogStaleResourceDetection(ctx context.Context, resourceType, resourceID string, reason string, action string)

LogStaleResourceDetection logs stale resource detection events

type Timer

type Timer struct {
	// contains filtered or unexported fields
}

Timer is a helper for timing operations

func NewTimer

func NewTimer() *Timer

NewTimer creates a new timer

func (*Timer) Duration

func (t *Timer) Duration() time.Duration

Duration returns the elapsed time since the timer was created

Jump to

Keyboard shortcuts

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