metrics

package
v1.0.78 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package metrics is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LockFreeRingBuffer

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

LockFreeRingBuffer is a lock-free ring buffer implementation.

func (*LockFreeRingBuffer) Add

func (b *LockFreeRingBuffer) Add(timestamp time.Time, responseTime int64, serviceName, deviceID, partition, agentID, pollerID string)

Add adds a new metric point to the buffer.

func (*LockFreeRingBuffer) GetLastPoint

func (b *LockFreeRingBuffer) GetLastPoint() *models.MetricPoint

func (*LockFreeRingBuffer) GetPoints

func (b *LockFreeRingBuffer) GetPoints() []models.MetricPoint

GetPoints retrieves all metric points from the buffer.

type Manager

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

func NewManager

func NewManager(cfg models.MetricsConfig, d db.Service, l logger.Logger) *Manager

func (*Manager) AddMetric

func (m *Manager) AddMetric(
	nodeID string, timestamp time.Time, responseTime int64, serviceName, deviceID, partition, agentID string) error

func (*Manager) CleanupStalePollers

func (m *Manager) CleanupStalePollers(staleDuration time.Duration)

func (*Manager) GetActiveNodes

func (m *Manager) GetActiveNodes() int64

func (*Manager) GetAllCPUMetrics

func (m *Manager) GetAllCPUMetrics(
	ctx context.Context, pollerID string, start, end time.Time) ([]models.SysmonCPUResponse, error)

GetAllCPUMetrics retrieves all CPU metrics for a poller.

func (*Manager) GetAllDiskMetrics

func (m *Manager) GetAllDiskMetrics(
	ctx context.Context, pollerID string, start, end time.Time) ([]models.DiskMetric, error)

GetAllDiskMetrics retrieves disk metrics for all mount points for a given poller.

func (*Manager) GetAllDiskMetricsGrouped

func (m *Manager) GetAllDiskMetricsGrouped(
	ctx context.Context, pollerID string, start, end time.Time) ([]models.SysmonDiskResponse, error)

GetAllDiskMetricsGrouped retrieves all disk metrics for a poller, grouped by timestamp.

func (*Manager) GetAllMountPoints

func (m *Manager) GetAllMountPoints(ctx context.Context, pollerID string) ([]string, error)

GetAllMountPoints retrieves all unique mount points for a given poller.

func (*Manager) GetAllProcessMetrics

func (m *Manager) GetAllProcessMetrics(
	ctx context.Context, pollerID string, start, end time.Time) ([]models.ProcessMetric, error)

GetAllProcessMetrics retrieves all process metrics for a poller.

func (*Manager) GetAllProcessMetricsGrouped

func (m *Manager) GetAllProcessMetricsGrouped(
	ctx context.Context, pollerID string, start, end time.Time) ([]models.SysmonProcessResponse, error)

GetAllProcessMetricsGrouped retrieves all process metrics for a poller, grouped by timestamp.

func (*Manager) GetCPUMetrics

func (m *Manager) GetCPUMetrics(
	ctx context.Context, pollerID string, coreID int, start, end time.Time) ([]models.CPUMetric, error)

func (*Manager) GetDevicesWithActiveMetrics

func (m *Manager) GetDevicesWithActiveMetrics() []string

func (*Manager) GetDiskMetrics

func (m *Manager) GetDiskMetrics(
	ctx context.Context, pollerID, mountPoint string, start, end time.Time) ([]models.DiskMetric, error)

func (*Manager) GetMemoryMetrics

func (m *Manager) GetMemoryMetrics(
	ctx context.Context, pollerID string, start, end time.Time) ([]models.MemoryMetric, error)

func (*Manager) GetMemoryMetricsGrouped

func (m *Manager) GetMemoryMetricsGrouped(
	ctx context.Context, pollerID string, start, end time.Time) ([]models.SysmonMemoryResponse, error)

GetMemoryMetricsGrouped retrieves all memory metrics for a poller, grouped by timestamp.

func (*Manager) GetMetrics

func (m *Manager) GetMetrics(nodeID string) []models.MetricPoint

func (*Manager) GetMetricsByDevice

func (m *Manager) GetMetricsByDevice(deviceID string) []models.MetricPoint

func (*Manager) GetRperfMetrics

func (m *Manager) GetRperfMetrics(ctx context.Context, pollerID, target string, start, end time.Time) ([]models.RperfMetric, error)

func (*Manager) StoreRperfMetrics

func (m *Manager) StoreRperfMetrics(ctx context.Context, pollerID string, metrics *models.RperfMetrics, timestamp time.Time) error

func (*Manager) StoreSysmonMetrics

func (m *Manager) StoreSysmonMetrics(
	ctx context.Context, pollerID, agentID, hostID, partition, hostIP, deviceID string, metrics *models.SysmonMetrics, timestamp time.Time) error

type MetricCollector

type MetricCollector interface {
	AddMetric(nodeID string, timestamp time.Time, responseTime int64, serviceName, deviceID, partition, agentID string) error
	GetMetrics(nodeID string) []models.MetricPoint
	GetMetricsByDevice(deviceID string) []models.MetricPoint
	GetDevicesWithActiveMetrics() []string
	CleanupStalePollers(staleDuration time.Duration)
}

type MetricStore

type MetricStore interface {
	Add(timestamp time.Time, responseTime int64, serviceName, deviceID, partition, agentID, pollerID string)
	GetPoints() []models.MetricPoint
	GetLastPoint() *models.MetricPoint // New method
}

func NewBuffer

func NewBuffer(size int) MetricStore

NewBuffer creates a new MetricStore (e.g., RingBuffer or LockFreeRingBuffer).

func NewLockFreeBuffer

func NewLockFreeBuffer(size int) MetricStore

NewLockFreeBuffer creates a new LockFreeRingBuffer with the specified size.

type MockMetricCollector

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

MockMetricCollector is a mock of MetricCollector interface.

func NewMockMetricCollector

func NewMockMetricCollector(ctrl *gomock.Controller) *MockMetricCollector

NewMockMetricCollector creates a new mock instance.

func (*MockMetricCollector) AddMetric

func (m *MockMetricCollector) AddMetric(nodeID string, timestamp time.Time, responseTime int64, serviceName, deviceID, partition, agentID string) error

AddMetric mocks base method.

func (*MockMetricCollector) CleanupStalePollers

func (m *MockMetricCollector) CleanupStalePollers(staleDuration time.Duration)

CleanupStalePollers mocks base method.

func (*MockMetricCollector) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMetricCollector) GetDevicesWithActiveMetrics

func (m *MockMetricCollector) GetDevicesWithActiveMetrics() []string

GetDevicesWithActiveMetrics mocks base method.

func (*MockMetricCollector) GetMetrics

func (m *MockMetricCollector) GetMetrics(nodeID string) []models.MetricPoint

GetMetrics mocks base method.

func (*MockMetricCollector) GetMetricsByDevice

func (m *MockMetricCollector) GetMetricsByDevice(deviceID string) []models.MetricPoint

GetMetricsByDevice mocks base method.

type MockMetricCollectorMockRecorder

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

MockMetricCollectorMockRecorder is the mock recorder for MockMetricCollector.

func (*MockMetricCollectorMockRecorder) AddMetric

func (mr *MockMetricCollectorMockRecorder) AddMetric(nodeID, timestamp, responseTime, serviceName, deviceID, partition, agentID any) *gomock.Call

AddMetric indicates an expected call of AddMetric.

func (*MockMetricCollectorMockRecorder) CleanupStalePollers

func (mr *MockMetricCollectorMockRecorder) CleanupStalePollers(staleDuration any) *gomock.Call

CleanupStalePollers indicates an expected call of CleanupStalePollers.

func (*MockMetricCollectorMockRecorder) GetDevicesWithActiveMetrics

func (mr *MockMetricCollectorMockRecorder) GetDevicesWithActiveMetrics() *gomock.Call

GetDevicesWithActiveMetrics indicates an expected call of GetDevicesWithActiveMetrics.

func (*MockMetricCollectorMockRecorder) GetMetrics

func (mr *MockMetricCollectorMockRecorder) GetMetrics(nodeID any) *gomock.Call

GetMetrics indicates an expected call of GetMetrics.

func (*MockMetricCollectorMockRecorder) GetMetricsByDevice

func (mr *MockMetricCollectorMockRecorder) GetMetricsByDevice(deviceID any) *gomock.Call

GetMetricsByDevice indicates an expected call of GetMetricsByDevice.

type MockMetricStore

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

MockMetricStore is a mock of MetricStore interface.

func NewMockMetricStore

func NewMockMetricStore(ctrl *gomock.Controller) *MockMetricStore

NewMockMetricStore creates a new mock instance.

func (*MockMetricStore) Add

func (m *MockMetricStore) Add(timestamp time.Time, responseTime int64, serviceName, deviceID, partition, agentID, pollerID string)

Add mocks base method.

func (*MockMetricStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMetricStore) GetLastPoint

func (m *MockMetricStore) GetLastPoint() *models.MetricPoint

GetLastPoint mocks base method.

func (*MockMetricStore) GetPoints

func (m *MockMetricStore) GetPoints() []models.MetricPoint

GetPoints mocks base method.

type MockMetricStoreMockRecorder

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

MockMetricStoreMockRecorder is the mock recorder for MockMetricStore.

func (*MockMetricStoreMockRecorder) Add

func (mr *MockMetricStoreMockRecorder) Add(timestamp, responseTime, serviceName, deviceID, partition, agentID, pollerID any) *gomock.Call

Add indicates an expected call of Add.

func (*MockMetricStoreMockRecorder) GetLastPoint

func (mr *MockMetricStoreMockRecorder) GetLastPoint() *gomock.Call

GetLastPoint indicates an expected call of GetLastPoint.

func (*MockMetricStoreMockRecorder) GetPoints

func (mr *MockMetricStoreMockRecorder) GetPoints() *gomock.Call

GetPoints indicates an expected call of GetPoints.

type MockStructuredMetricCollector

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

MockStructuredMetricCollector is a mock of StructuredMetricCollector interface.

func NewMockStructuredMetricCollector

func NewMockStructuredMetricCollector(ctrl *gomock.Controller) *MockStructuredMetricCollector

NewMockStructuredMetricCollector creates a new mock instance.

func (*MockStructuredMetricCollector) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockStructuredMetricCollector) GetAllDiskMetrics

func (m *MockStructuredMetricCollector) GetAllDiskMetrics(ctx context.Context, pollerID string, start, end time.Time) ([]models.DiskMetric, error)

GetAllDiskMetrics mocks base method.

func (*MockStructuredMetricCollector) GetCPUMetrics

func (m *MockStructuredMetricCollector) GetCPUMetrics(ctx context.Context, pollerID string, coreID int, start, end time.Time) ([]models.CPUMetric, error)

GetCPUMetrics mocks base method.

func (*MockStructuredMetricCollector) GetDiskMetrics

func (m *MockStructuredMetricCollector) GetDiskMetrics(ctx context.Context, pollerID, mountPoint string, start, end time.Time) ([]models.DiskMetric, error)

GetDiskMetrics mocks base method.

func (*MockStructuredMetricCollector) GetMemoryMetrics

func (m *MockStructuredMetricCollector) GetMemoryMetrics(ctx context.Context, pollerID string, start, end time.Time) ([]models.MemoryMetric, error)

GetMemoryMetrics mocks base method.

func (*MockStructuredMetricCollector) GetRperfMetrics

func (m *MockStructuredMetricCollector) GetRperfMetrics(ctx context.Context, pollerID, target string, start, end time.Time) ([]models.RperfMetric, error)

GetRperfMetrics mocks base method.

func (*MockStructuredMetricCollector) StoreRperfMetrics

func (m *MockStructuredMetricCollector) StoreRperfMetrics(ctx context.Context, pollerID string, metrics *models.RperfMetrics, timestamp time.Time) error

StoreRperfMetrics mocks base method.

func (*MockStructuredMetricCollector) StoreSysmonMetrics

func (m *MockStructuredMetricCollector) StoreSysmonMetrics(ctx context.Context, pollerID, agentID, hostID, partition, hostIP, deviceID string, metrics *models.SysmonMetrics, timestamp time.Time) error

StoreSysmonMetrics mocks base method.

type MockStructuredMetricCollectorMockRecorder

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

MockStructuredMetricCollectorMockRecorder is the mock recorder for MockStructuredMetricCollector.

func (*MockStructuredMetricCollectorMockRecorder) GetAllDiskMetrics

func (mr *MockStructuredMetricCollectorMockRecorder) GetAllDiskMetrics(ctx, pollerID, start, end any) *gomock.Call

GetAllDiskMetrics indicates an expected call of GetAllDiskMetrics.

func (*MockStructuredMetricCollectorMockRecorder) GetCPUMetrics

func (mr *MockStructuredMetricCollectorMockRecorder) GetCPUMetrics(ctx, pollerID, coreID, start, end any) *gomock.Call

GetCPUMetrics indicates an expected call of GetCPUMetrics.

func (*MockStructuredMetricCollectorMockRecorder) GetDiskMetrics

func (mr *MockStructuredMetricCollectorMockRecorder) GetDiskMetrics(ctx, pollerID, mountPoint, start, end any) *gomock.Call

GetDiskMetrics indicates an expected call of GetDiskMetrics.

func (*MockStructuredMetricCollectorMockRecorder) GetMemoryMetrics

func (mr *MockStructuredMetricCollectorMockRecorder) GetMemoryMetrics(ctx, pollerID, start, end any) *gomock.Call

GetMemoryMetrics indicates an expected call of GetMemoryMetrics.

func (*MockStructuredMetricCollectorMockRecorder) GetRperfMetrics

func (mr *MockStructuredMetricCollectorMockRecorder) GetRperfMetrics(ctx, pollerID, target, start, end any) *gomock.Call

GetRperfMetrics indicates an expected call of GetRperfMetrics.

func (*MockStructuredMetricCollectorMockRecorder) StoreRperfMetrics

func (mr *MockStructuredMetricCollectorMockRecorder) StoreRperfMetrics(ctx, pollerID, metrics, timestamp any) *gomock.Call

StoreRperfMetrics indicates an expected call of StoreRperfMetrics.

func (*MockStructuredMetricCollectorMockRecorder) StoreSysmonMetrics

func (mr *MockStructuredMetricCollectorMockRecorder) StoreSysmonMetrics(ctx, pollerID, agentID, hostID, partition, hostIP, deviceID, metrics, timestamp any) *gomock.Call

StoreSysmonMetrics indicates an expected call of StoreSysmonMetrics.

type MockSysmonMetricsProvider

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

MockSysmonMetricsProvider is a mock of SysmonMetricsProvider interface.

func NewMockSysmonMetricsProvider

func NewMockSysmonMetricsProvider(ctrl *gomock.Controller) *MockSysmonMetricsProvider

NewMockSysmonMetricsProvider creates a new mock instance.

func (*MockSysmonMetricsProvider) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSysmonMetricsProvider) GetAllCPUMetrics

func (m *MockSysmonMetricsProvider) GetAllCPUMetrics(ctx context.Context, pollerID string, start, end time.Time) ([]models.SysmonCPUResponse, error)

GetAllCPUMetrics mocks base method.

func (*MockSysmonMetricsProvider) GetAllDiskMetricsGrouped

func (m *MockSysmonMetricsProvider) GetAllDiskMetricsGrouped(ctx context.Context, pollerID string, start, end time.Time) ([]models.SysmonDiskResponse, error)

GetAllDiskMetricsGrouped mocks base method.

func (*MockSysmonMetricsProvider) GetCPUMetrics

func (m *MockSysmonMetricsProvider) GetCPUMetrics(ctx context.Context, pollerID string, coreID int, start, end time.Time) ([]models.CPUMetric, error)

GetCPUMetrics mocks base method.

func (*MockSysmonMetricsProvider) GetDiskMetrics

func (m *MockSysmonMetricsProvider) GetDiskMetrics(ctx context.Context, pollerID, mountPoint string, start, end time.Time) ([]models.DiskMetric, error)

GetDiskMetrics mocks base method.

func (*MockSysmonMetricsProvider) GetMemoryMetricsGrouped

func (m *MockSysmonMetricsProvider) GetMemoryMetricsGrouped(ctx context.Context, pollerID string, start, end time.Time) ([]models.SysmonMemoryResponse, error)

GetMemoryMetricsGrouped mocks base method.

type MockSysmonMetricsProviderMockRecorder

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

MockSysmonMetricsProviderMockRecorder is the mock recorder for MockSysmonMetricsProvider.

func (*MockSysmonMetricsProviderMockRecorder) GetAllCPUMetrics

func (mr *MockSysmonMetricsProviderMockRecorder) GetAllCPUMetrics(ctx, pollerID, start, end any) *gomock.Call

GetAllCPUMetrics indicates an expected call of GetAllCPUMetrics.

func (*MockSysmonMetricsProviderMockRecorder) GetAllDiskMetricsGrouped

func (mr *MockSysmonMetricsProviderMockRecorder) GetAllDiskMetricsGrouped(ctx, pollerID, start, end any) *gomock.Call

GetAllDiskMetricsGrouped indicates an expected call of GetAllDiskMetricsGrouped.

func (*MockSysmonMetricsProviderMockRecorder) GetCPUMetrics

func (mr *MockSysmonMetricsProviderMockRecorder) GetCPUMetrics(ctx, pollerID, coreID, start, end any) *gomock.Call

GetCPUMetrics indicates an expected call of GetCPUMetrics.

func (*MockSysmonMetricsProviderMockRecorder) GetDiskMetrics

func (mr *MockSysmonMetricsProviderMockRecorder) GetDiskMetrics(ctx, pollerID, mountPoint, start, end any) *gomock.Call

GetDiskMetrics indicates an expected call of GetDiskMetrics.

func (*MockSysmonMetricsProviderMockRecorder) GetMemoryMetricsGrouped

func (mr *MockSysmonMetricsProviderMockRecorder) GetMemoryMetricsGrouped(ctx, pollerID, start, end any) *gomock.Call

GetMemoryMetricsGrouped indicates an expected call of GetMemoryMetricsGrouped.

type StructuredMetricCollector

type StructuredMetricCollector interface {
	StoreSysmonMetrics(ctx context.Context, pollerID, agentID, hostID, partition, hostIP, deviceID string, metrics *models.SysmonMetrics, timestamp time.Time) error
	GetCPUMetrics(ctx context.Context, pollerID string, coreID int, start, end time.Time) ([]models.CPUMetric, error)
	GetDiskMetrics(ctx context.Context, pollerID, mountPoint string, start, end time.Time) ([]models.DiskMetric, error)
	GetMemoryMetrics(ctx context.Context, pollerID string, start, end time.Time) ([]models.MemoryMetric, error)
	GetAllDiskMetrics(ctx context.Context, pollerID string, start, end time.Time) ([]models.DiskMetric, error)

	StoreRperfMetrics(ctx context.Context, pollerID string, metrics *models.RperfMetrics, timestamp time.Time) error
	GetRperfMetrics(ctx context.Context, pollerID string, target string, start, end time.Time) ([]models.RperfMetric, error)
}

type SysmonMetricsProvider

type SysmonMetricsProvider interface {
	GetAllCPUMetrics(ctx context.Context, pollerID string, start, end time.Time) ([]models.SysmonCPUResponse, error)
	GetCPUMetrics(ctx context.Context, pollerID string, coreID int, start, end time.Time) ([]models.CPUMetric, error)
	GetAllDiskMetricsGrouped(ctx context.Context, pollerID string, start, end time.Time) ([]models.SysmonDiskResponse, error)
	GetDiskMetrics(ctx context.Context, pollerID, mountPoint string, start, end time.Time) ([]models.DiskMetric, error)
	GetMemoryMetricsGrouped(ctx context.Context, pollerID string, start, end time.Time) ([]models.SysmonMemoryResponse, error)
}

SysmonMetricsProvider interface extension.

Jump to

Keyboard shortcuts

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