metrics

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheCollector

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

CacheCollector wraps Redis client with metrics

func NewCacheCollector

func NewCacheCollector(client *redis.Client, collector CacheMetricsCollector) *CacheCollector

NewCacheCollector creates a cache collector wrapper

func (*CacheCollector) Del

func (c *CacheCollector) Del(ctx context.Context, keys ...string) *redis.IntCmd

Del wraps Redis DEL with metrics

func (*CacheCollector) Get

func (c *CacheCollector) Get(ctx context.Context, key string) *redis.StringCmd

Get wraps Redis GET with metrics

func (*CacheCollector) GetClient

func (c *CacheCollector) GetClient() *redis.Client

GetClient returns the underlying Redis client

func (*CacheCollector) HDel

func (c *CacheCollector) HDel(ctx context.Context, key string, fields ...string) *redis.IntCmd

HDel wraps Redis HDEL with metrics

func (*CacheCollector) HGet

func (c *CacheCollector) HGet(ctx context.Context, key, field string) *redis.StringCmd

HGet wraps Redis HGET with metrics

func (*CacheCollector) HSet

func (c *CacheCollector) HSet(ctx context.Context, key string, values ...any) *redis.IntCmd

HSet wraps Redis HSET with metrics

func (*CacheCollector) Ping

Ping wraps Redis PING with metrics

func (*CacheCollector) PoolStats

func (c *CacheCollector) PoolStats() *redis.PoolStats

PoolStats returns pool statistics and updates metrics

func (*CacheCollector) Set

func (c *CacheCollector) Set(ctx context.Context, key string, value any, expiration time.Duration) *redis.StatusCmd

Set wraps Redis SET with metrics

type CacheMetricsCollector

type CacheMetricsCollector interface {
	RedisCommand(command string, err error)
}

CacheMetricsCollector for Redis cache operations

type Collector

type Collector interface {
	DBQuery(duration time.Duration, err error)
	DBTransaction(err error)
	DBConnections(count int)

	RedisCommand(command string, err error)
	RedisConnections(count int)

	MongoOperation(operation string, err error)

	SearchQuery(engine string, err error)
	SearchIndex(engine, operation string)

	MQPublish(system string, err error)
	MQConsume(system string, err error)

	HealthCheck(component string, healthy bool)
}

Collector defines interface for data layer metrics collection

type DefaultCollector

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

DefaultCollector provides basic metrics collection with atomic counters

func NewDefaultCollector

func NewDefaultCollector() *DefaultCollector

NewDefaultCollector creates a new default collector

func (*DefaultCollector) DBConnections

func (c *DefaultCollector) DBConnections(count int)

DBConnections Database connection metrics

func (*DefaultCollector) DBQuery

func (c *DefaultCollector) DBQuery(duration time.Duration, err error)

DBQuery Database query metrics

func (*DefaultCollector) DBTransaction

func (c *DefaultCollector) DBTransaction(err error)

DBTransaction Database transaction metrics

func (*DefaultCollector) GetStats

func (c *DefaultCollector) GetStats() map[string]any

GetStats returns comprehensive statistics

func (*DefaultCollector) HealthCheck

func (c *DefaultCollector) HealthCheck(component string, healthy bool)

HealthCheck Health check

func (*DefaultCollector) MQConsume

func (c *DefaultCollector) MQConsume(system string, err error)

MQConsume Message queue consume metrics

func (*DefaultCollector) MQPublish

func (c *DefaultCollector) MQPublish(system string, err error)

MQPublish Message queue publish metrics

func (*DefaultCollector) MongoOperation

func (c *DefaultCollector) MongoOperation(operation string, err error)

MongoOperation MongoDB operation metrics

func (*DefaultCollector) RedisCommand

func (c *DefaultCollector) RedisCommand(command string, err error)

RedisCommand Redis command metrics

func (*DefaultCollector) RedisConnections

func (c *DefaultCollector) RedisConnections(count int)

RedisConnections Redis connection metrics

func (*DefaultCollector) SearchIndex

func (c *DefaultCollector) SearchIndex(engine, operation string)

SearchIndex Search index metrics

func (*DefaultCollector) SearchQuery

func (c *DefaultCollector) SearchQuery(engine string, err error)

SearchQuery Search query metrics

type ExtensionCollector

type ExtensionCollector interface {
	DBQuery(duration time.Duration, err error)
	DBTransaction(err error)
	DBConnections(count int)
	RedisCommand(command string, err error)
	RedisConnections(count int)
	MongoOperation(operation string, err error)
	SearchQuery(engine string, err error)
	SearchIndex(engine, operation string)
	MQPublish(system string, err error)
	MQConsume(system string, err error)
	HealthCheck(component string, healthy bool)
}

ExtensionCollector interface from extension layer

type ExtensionCollectorAdapter

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

ExtensionCollectorAdapter adapts extension metrics collector to data layer interface

func NewExtensionCollectorAdapter

func NewExtensionCollectorAdapter(collector ExtensionCollector) *ExtensionCollectorAdapter

NewExtensionCollectorAdapter creates adapter for extension collector

func (*ExtensionCollectorAdapter) DBConnections

func (a *ExtensionCollectorAdapter) DBConnections(count int)

func (*ExtensionCollectorAdapter) DBQuery

func (a *ExtensionCollectorAdapter) DBQuery(duration time.Duration, err error)

Implement data layer Collector interface

func (*ExtensionCollectorAdapter) DBTransaction

func (a *ExtensionCollectorAdapter) DBTransaction(err error)

func (*ExtensionCollectorAdapter) HealthCheck

func (a *ExtensionCollectorAdapter) HealthCheck(component string, healthy bool)

func (*ExtensionCollectorAdapter) MQConsume

func (a *ExtensionCollectorAdapter) MQConsume(system string, err error)

func (*ExtensionCollectorAdapter) MQPublish

func (a *ExtensionCollectorAdapter) MQPublish(system string, err error)

func (*ExtensionCollectorAdapter) MongoOperation

func (a *ExtensionCollectorAdapter) MongoOperation(operation string, err error)

func (*ExtensionCollectorAdapter) RedisCommand

func (a *ExtensionCollectorAdapter) RedisCommand(command string, err error)

func (*ExtensionCollectorAdapter) RedisConnections

func (a *ExtensionCollectorAdapter) RedisConnections(count int)

func (*ExtensionCollectorAdapter) SearchIndex

func (a *ExtensionCollectorAdapter) SearchIndex(engine, operation string)

func (*ExtensionCollectorAdapter) SearchQuery

func (a *ExtensionCollectorAdapter) SearchQuery(engine string, err error)

type HealthChecker

type HealthChecker interface {
	Check(ctx context.Context) error
	Name() string
}

HealthChecker interface for health checking

type HealthMonitor

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

HealthMonitor monitors data layer component health

func NewHealthMonitor

func NewHealthMonitor(collector Collector) *HealthMonitor

NewHealthMonitor creates a new health monitor

func (*HealthMonitor) CheckAll

func (h *HealthMonitor) CheckAll(ctx context.Context) map[string]bool

CheckAll performs health check on all registered components

func (*HealthMonitor) CheckComponent

func (h *HealthMonitor) CheckComponent(ctx context.Context, name string) bool

CheckComponent checks a specific component

func (*HealthMonitor) RegisterComponent

func (h *HealthMonitor) RegisterComponent(checker HealthChecker)

RegisterComponent registers a component for health monitoring

type NoOpCollector

type NoOpCollector struct{}

NoOpCollector implements Collector with no-op methods

func (NoOpCollector) DBConnections

func (NoOpCollector) DBConnections(int)

func (NoOpCollector) DBQuery

func (NoOpCollector) DBQuery(time.Duration, error)

func (NoOpCollector) DBTransaction

func (NoOpCollector) DBTransaction(error)

func (NoOpCollector) HealthCheck

func (NoOpCollector) HealthCheck(string, bool)

func (NoOpCollector) MQConsume

func (NoOpCollector) MQConsume(string, error)

func (NoOpCollector) MQPublish

func (NoOpCollector) MQPublish(string, error)

func (NoOpCollector) MongoOperation

func (NoOpCollector) MongoOperation(string, error)

func (NoOpCollector) RedisCommand

func (NoOpCollector) RedisCommand(string, error)

func (NoOpCollector) RedisConnections

func (NoOpCollector) RedisConnections(int)

func (NoOpCollector) SearchIndex

func (NoOpCollector) SearchIndex(string, string)

func (NoOpCollector) SearchQuery

func (NoOpCollector) SearchQuery(string, error)

Jump to

Keyboard shortcuts

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