Documentation
¶
Index ¶
- type AggregationResult
- type MemoryStorage
- func (ms *MemoryStorage) Aggregate(ctx context.Context, aggregation MetricsAggregation) (*AggregationResult, error)
- func (ms *MemoryStorage) Backup(ctx context.Context) ([]byte, error)
- func (ms *MemoryStorage) Clear(ctx context.Context) error
- func (ms *MemoryStorage) Count(ctx context.Context) (int64, error)
- func (ms *MemoryStorage) Delete(ctx context.Context, name string, tags map[string]string) error
- func (ms *MemoryStorage) Health(ctx context.Context) error
- func (ms *MemoryStorage) List(ctx context.Context, filters map[string]string) ([]*MetricEntry, error)
- func (ms *MemoryStorage) Query(ctx context.Context, query MetricsQuery) (*QueryResult, error)
- func (ms *MemoryStorage) Restore(ctx context.Context, data []byte) error
- func (ms *MemoryStorage) Retrieve(ctx context.Context, name string, tags map[string]string) (*MetricEntry, error)
- func (ms *MemoryStorage) Start(ctx context.Context) error
- func (ms *MemoryStorage) Stats(ctx context.Context) (interface{}, error)
- func (ms *MemoryStorage) Stop(ctx context.Context) error
- func (ms *MemoryStorage) Store(ctx context.Context, entry *MetricEntry) error
- type MemoryStorageBackup
- type MemoryStorageConfig
- type MemoryStorageStats
- type MetricEntry
- type MetricsAggregation
- type MetricsQuery
- type MetricsStorage
- type QueryResult
- type RedisStorage
- func (rs *RedisStorage) Aggregate(ctx context.Context, aggregation MetricsAggregation) (*AggregationResult, error)
- func (rs *RedisStorage) Backup(ctx context.Context) ([]byte, error)
- func (rs *RedisStorage) Clear(ctx context.Context) error
- func (rs *RedisStorage) Count(ctx context.Context) (int64, error)
- func (rs *RedisStorage) Delete(ctx context.Context, name string, tags map[string]string) error
- func (rs *RedisStorage) Health(ctx context.Context) error
- func (rs *RedisStorage) List(ctx context.Context, filters map[string]string) ([]*MetricEntry, error)
- func (rs *RedisStorage) Query(ctx context.Context, query MetricsQuery) (*QueryResult, error)
- func (rs *RedisStorage) Restore(ctx context.Context, data []byte) error
- func (rs *RedisStorage) Retrieve(ctx context.Context, name string, tags map[string]string) (*MetricEntry, error)
- func (rs *RedisStorage) SetLogger(logger logger.Logger)
- func (rs *RedisStorage) Start(ctx context.Context) error
- func (rs *RedisStorage) Stats(ctx context.Context) (interface{}, error)
- func (rs *RedisStorage) Stop(ctx context.Context) error
- func (rs *RedisStorage) Store(ctx context.Context, entry *MetricEntry) error
- type RedisStorageBackup
- type RedisStorageConfig
- type RedisStorageStats
- type TimeAggregationData
- type TimeAggregationQuery
- type TimeAggregationResult
- type TimeRangeQuery
- type TimeRangeResult
- type TimeSeries
- type TimeSeriesData
- type TimeSeriesPoint
- type TimeSeriesStorage
- func (ts *TimeSeriesStorage) AggregateRange(ctx context.Context, query TimeAggregationQuery) (*TimeAggregationResult, error)
- func (ts *TimeSeriesStorage) Clear(ctx context.Context) error
- func (ts *TimeSeriesStorage) Count(ctx context.Context) (int64, error)
- func (ts *TimeSeriesStorage) Delete(ctx context.Context, name string, tags map[string]string) error
- func (ts *TimeSeriesStorage) Health(ctx context.Context) error
- func (ts *TimeSeriesStorage) List(ctx context.Context, filters map[string]string) ([]*MetricEntry, error)
- func (ts *TimeSeriesStorage) QueryRange(ctx context.Context, query TimeRangeQuery) (*TimeRangeResult, error)
- func (ts *TimeSeriesStorage) Retrieve(ctx context.Context, name string, tags map[string]string) (*MetricEntry, error)
- func (ts *TimeSeriesStorage) SetLogger(logger logger.Logger)
- func (ts *TimeSeriesStorage) Start(ctx context.Context) error
- func (ts *TimeSeriesStorage) Stats(ctx context.Context) (interface{}, error)
- func (ts *TimeSeriesStorage) Stop(ctx context.Context) error
- func (ts *TimeSeriesStorage) Store(ctx context.Context, entry *MetricEntry) error
- type TimeSeriesStorageConfig
- type TimeSeriesStorageStats
- type TimeWindow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregationResult ¶
type AggregationResult struct {
Function string `json:"function"`
Filters map[string]string `json:"filters"`
Value float64 `json:"value"`
Count int `json:"count"`
Timestamp time.Time `json:"timestamp"`
}
AggregationResult represents the result of an aggregation
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage provides in-memory storage for metrics
func (*MemoryStorage) Aggregate ¶
func (ms *MemoryStorage) Aggregate(ctx context.Context, aggregation MetricsAggregation) (*AggregationResult, error)
Aggregate performs aggregation on stored metrics
func (*MemoryStorage) Backup ¶
func (ms *MemoryStorage) Backup(ctx context.Context) ([]byte, error)
Backup creates a backup of all stored metrics
func (*MemoryStorage) Clear ¶
func (ms *MemoryStorage) Clear(ctx context.Context) error
Clear clears all stored entries
func (*MemoryStorage) Count ¶
func (ms *MemoryStorage) Count(ctx context.Context) (int64, error)
Count returns the number of stored entries
func (*MemoryStorage) Health ¶
func (ms *MemoryStorage) Health(ctx context.Context) error
Health checks the health of the storage system
func (*MemoryStorage) List ¶
func (ms *MemoryStorage) List(ctx context.Context, filters map[string]string) ([]*MetricEntry, error)
List lists all metric entries
func (*MemoryStorage) Query ¶
func (ms *MemoryStorage) Query(ctx context.Context, query MetricsQuery) (*QueryResult, error)
Query performs a query on stored metrics
func (*MemoryStorage) Restore ¶
func (ms *MemoryStorage) Restore(ctx context.Context, data []byte) error
Restore restores metrics from a backup
func (*MemoryStorage) Retrieve ¶
func (ms *MemoryStorage) Retrieve(ctx context.Context, name string, tags map[string]string) (*MetricEntry, error)
Retrieve retrieves a metric entry
func (*MemoryStorage) Start ¶
func (ms *MemoryStorage) Start(ctx context.Context) error
Start starts the storage system
func (*MemoryStorage) Stats ¶
func (ms *MemoryStorage) Stats(ctx context.Context) (interface{}, error)
Stats returns storage statistics
func (*MemoryStorage) Stop ¶
func (ms *MemoryStorage) Stop(ctx context.Context) error
Stop stops the storage system
func (*MemoryStorage) Store ¶
func (ms *MemoryStorage) Store(ctx context.Context, entry *MetricEntry) error
Store stores a metric entry
type MemoryStorageBackup ¶
type MemoryStorageBackup struct {
Timestamp time.Time `json:"timestamp"`
Entries []*MetricEntry `json:"entries"`
Stats MemoryStorageStats `json:"stats"`
}
MemoryStorageBackup represents a backup of memory storage
type MemoryStorageConfig ¶
type MemoryStorageConfig struct {
MaxEntries int `yaml:"max_entries" json:"max_entries"`
Retention time.Duration `yaml:"retention" json:"retention"`
CleanupInterval time.Duration `yaml:"cleanup_interval" json:"cleanup_interval"`
EnableStats bool `yaml:"enable_stats" json:"enable_stats"`
}
MemoryStorageConfig contains configuration for memory storage
func DefaultMemoryStorageConfig ¶
func DefaultMemoryStorageConfig() *MemoryStorageConfig
DefaultMemoryStorageConfig returns default configuration
type MemoryStorageStats ¶
type MemoryStorageStats struct {
EntriesCount int64 `json:"entries_count"`
MaxEntries int `json:"max_entries"`
StorageSize int64 `json:"storage_size"`
TotalWrites int64 `json:"total_writes"`
TotalReads int64 `json:"total_reads"`
TotalDeletes int64 `json:"total_deletes"`
CleanupRuns int64 `json:"cleanup_runs"`
LastCleanup time.Time `json:"last_cleanup"`
AverageEntrySize float64 `json:"average_entry_size"`
OldestEntry time.Time `json:"oldest_entry"`
NewestEntry time.Time `json:"newest_entry"`
MemoryUsage int64 `json:"memory_usage"`
HitRate float64 `json:"hit_rate"`
Uptime time.Duration `json:"uptime"`
// contains filtered or unexported fields
}
MemoryStorageStats contains statistics about memory storage
type MetricEntry ¶
type MetricEntry struct {
Name string `json:"name"`
Type shared.MetricType `json:"type"`
Value interface{} `json:"value"`
Tags map[string]string `json:"tags"`
Timestamp time.Time `json:"timestamp"`
LastUpdated time.Time `json:"last_updated"`
AccessCount int64 `json:"access_count"`
Metadata map[string]interface{} `json:"metadata"`
}
MetricEntry represents a stored metric entry
type MetricsAggregation ¶
type MetricsAggregation struct {
Function string `json:"function"`
Filters map[string]string `json:"filters"`
GroupBy []string `json:"group_by"`
}
MetricsAggregation represents an aggregation operation
type MetricsQuery ¶
type MetricsQuery struct {
Filters map[string]string `json:"filters"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
SortBy string `json:"sort_by"`
SortOrder string `json:"sort_order"`
Limit int `json:"limit"`
Offset int `json:"offset"`
}
MetricsQuery represents a query for metrics
type MetricsStorage ¶
type MetricsStorage interface {
Store(ctx context.Context, entry *MetricEntry) error
Retrieve(ctx context.Context, name string, tags map[string]string) (*MetricEntry, error)
Delete(ctx context.Context, name string, tags map[string]string) error
List(ctx context.Context, filters map[string]string) ([]*MetricEntry, error)
Count(ctx context.Context) (int64, error)
Clear(ctx context.Context) error
Start(ctx context.Context) error
Stop(ctx context.Context) error
Health(ctx context.Context) error
Stats(ctx context.Context) (interface{}, error)
}
MetricsStorage defines the interface for metrics storage
func NewMemoryStorage ¶
func NewMemoryStorage() MetricsStorage
NewMemoryStorage creates a new memory storage instance
func NewMemoryStorageWithConfig ¶
func NewMemoryStorageWithConfig(config *MemoryStorageConfig) MetricsStorage
NewMemoryStorageWithConfig creates a new memory storage instance with configuration
func NewRedisStorage ¶
func NewRedisStorage() MetricsStorage
NewRedisStorage creates a new Redis storage instance
func NewRedisStorageWithConfig ¶
func NewRedisStorageWithConfig(config *RedisStorageConfig) MetricsStorage
NewRedisStorageWithConfig creates a new Redis storage instance with configuration
func NewTimeSeriesStorage ¶
func NewTimeSeriesStorage() MetricsStorage
NewTimeSeriesStorage creates a new time-series storage instance
type QueryResult ¶
type QueryResult struct {
Entries []*MetricEntry `json:"entries"`
TotalCount int `json:"total_count"`
Query MetricsQuery `json:"query"`
Timestamp time.Time `json:"timestamp"`
}
QueryResult represents the result of a query
type RedisStorage ¶
type RedisStorage struct {
// contains filtered or unexported fields
}
RedisStorage provides Redis-backed storage for metrics
func (*RedisStorage) Aggregate ¶
func (rs *RedisStorage) Aggregate(ctx context.Context, aggregation MetricsAggregation) (*AggregationResult, error)
Aggregate performs aggregation on stored metrics
func (*RedisStorage) Backup ¶
func (rs *RedisStorage) Backup(ctx context.Context) ([]byte, error)
Backup creates a backup of all stored metrics
func (*RedisStorage) Clear ¶
func (rs *RedisStorage) Clear(ctx context.Context) error
Clear clears all stored entries
func (*RedisStorage) Count ¶
func (rs *RedisStorage) Count(ctx context.Context) (int64, error)
Count returns the number of stored entries
func (*RedisStorage) Health ¶
func (rs *RedisStorage) Health(ctx context.Context) error
Health checks the health of the Redis storage system
func (*RedisStorage) List ¶
func (rs *RedisStorage) List(ctx context.Context, filters map[string]string) ([]*MetricEntry, error)
List lists all metric entries matching filters
func (*RedisStorage) Query ¶
func (rs *RedisStorage) Query(ctx context.Context, query MetricsQuery) (*QueryResult, error)
Query performs a query on stored metrics
func (*RedisStorage) Restore ¶
func (rs *RedisStorage) Restore(ctx context.Context, data []byte) error
Restore restores metrics from a backup
func (*RedisStorage) Retrieve ¶
func (rs *RedisStorage) Retrieve(ctx context.Context, name string, tags map[string]string) (*MetricEntry, error)
Retrieve retrieves a metric entry from Redis
func (*RedisStorage) SetLogger ¶
func (rs *RedisStorage) SetLogger(logger logger.Logger)
SetLogger sets the logger for the Redis storage
func (*RedisStorage) Start ¶
func (rs *RedisStorage) Start(ctx context.Context) error
Start starts the Redis storage system
func (*RedisStorage) Stats ¶
func (rs *RedisStorage) Stats(ctx context.Context) (interface{}, error)
Stats returns storage statistics
func (*RedisStorage) Stop ¶
func (rs *RedisStorage) Stop(ctx context.Context) error
Stop stops the Redis storage system
func (*RedisStorage) Store ¶
func (rs *RedisStorage) Store(ctx context.Context, entry *MetricEntry) error
Store stores a metric entry in Redis
type RedisStorageBackup ¶
type RedisStorageBackup struct {
Timestamp time.Time `json:"timestamp"`
Entries []*MetricEntry `json:"entries"`
Stats RedisStorageStats `json:"stats"`
}
RedisStorageBackup represents a backup of Redis storage
type RedisStorageConfig ¶
type RedisStorageConfig struct {
Address string `yaml:"address" json:"address"`
Password string `yaml:"password" json:"password"`
Database int `yaml:"database" json:"database"`
KeyPrefix string `yaml:"key_prefix" json:"key_prefix"`
PoolSize int `yaml:"pool_size" json:"pool_size"`
MinIdleConns int `yaml:"min_idle_conns" json:"min_idle_conns"`
MaxRetries int `yaml:"max_retries" json:"max_retries"`
DialTimeout time.Duration `yaml:"dial_timeout" json:"dial_timeout"`
ReadTimeout time.Duration `yaml:"read_timeout" json:"read_timeout"`
WriteTimeout time.Duration `yaml:"write_timeout" json:"write_timeout"`
Retention time.Duration `yaml:"retention" json:"retention"`
CleanupInterval time.Duration `yaml:"cleanup_interval" json:"cleanup_interval"`
EnableStats bool `yaml:"enable_stats" json:"enable_stats"`
}
RedisStorageConfig contains configuration for Redis storage
func DefaultRedisStorageConfig ¶
func DefaultRedisStorageConfig() *RedisStorageConfig
DefaultRedisStorageConfig returns default configuration
type RedisStorageStats ¶
type RedisStorageStats struct {
Address string `json:"address"`
Connected bool `json:"connected"`
PoolSize int `json:"pool_size"`
TotalConns int `json:"total_conns"`
IdleConns int `json:"idle_conns"`
StaleConns int `json:"stale_conns"`
EntriesCount int64 `json:"entries_count"`
TotalWrites int64 `json:"total_writes"`
TotalReads int64 `json:"total_reads"`
TotalDeletes int64 `json:"total_deletes"`
FailedWrites int64 `json:"failed_writes"`
FailedReads int64 `json:"failed_reads"`
FailedDeletes int64 `json:"failed_deletes"`
CleanupRuns int64 `json:"cleanup_runs"`
LastCleanup time.Time `json:"last_cleanup"`
AverageEntrySize float64 `json:"average_entry_size"`
KeyspaceSize int64 `json:"keyspace_size"`
HitRate float64 `json:"hit_rate"`
Uptime time.Duration `json:"uptime"`
// contains filtered or unexported fields
}
RedisStorageStats contains statistics about Redis storage
type TimeAggregationData ¶
type TimeAggregationData struct {
Name string `json:"name"`
Tags map[string]string `json:"tags"`
Function string `json:"function"`
Windows []*TimeWindow `json:"windows"`
}
TimeAggregationData represents aggregated time series data
type TimeAggregationQuery ¶
type TimeAggregationQuery struct {
Filters map[string]string `json:"filters"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
Step time.Duration `json:"step"`
Function string `json:"function"`
}
TimeAggregationQuery represents a time aggregation query
type TimeAggregationResult ¶
type TimeAggregationResult struct {
Data []*TimeAggregationData `json:"data"`
Query TimeAggregationQuery `json:"query"`
Timestamp time.Time `json:"timestamp"`
}
TimeAggregationResult represents the result of a time aggregation query
type TimeRangeQuery ¶
type TimeRangeQuery struct {
Filters map[string]string `json:"filters"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
Step time.Duration `json:"step"`
}
TimeRangeQuery represents a time range query
type TimeRangeResult ¶
type TimeRangeResult struct {
Data []*TimeSeriesData `json:"data"`
Query TimeRangeQuery `json:"query"`
Timestamp time.Time `json:"timestamp"`
}
TimeRangeResult represents the result of a time range query
type TimeSeries ¶
type TimeSeries struct {
Name string `json:"name"`
Tags map[string]string `json:"tags"`
Type shared.MetricType `json:"type"`
Unit string `json:"unit"`
Points []*TimeSeriesPoint `json:"points"`
Buckets map[int64]*TimeWindow `json:"buckets"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
AccessCount int64 `json:"access_count"`
Metadata map[string]interface{} `json:"metadata"`
// contains filtered or unexported fields
}
TimeSeries represents a time-series of metric data points
type TimeSeriesData ¶
type TimeSeriesData struct {
Name string `json:"name"`
Tags map[string]string `json:"tags"`
Points []*TimeSeriesPoint `json:"points"`
}
TimeSeriesData represents time series data
type TimeSeriesPoint ¶
type TimeSeriesPoint struct {
Timestamp time.Time `json:"timestamp"`
Value float64 `json:"value"`
Tags map[string]string `json:"tags,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
TimeSeriesPoint represents a single data point in a time series
type TimeSeriesStorage ¶
type TimeSeriesStorage struct {
// contains filtered or unexported fields
}
TimeSeriesStorage provides time-series storage for metrics with efficient time-based operations
func NewTimeSeriesStorageWithConfig ¶
func NewTimeSeriesStorageWithConfig(config *TimeSeriesStorageConfig) *TimeSeriesStorage
NewTimeSeriesStorageWithConfig creates a new time-series storage instance with configuration
func (*TimeSeriesStorage) AggregateRange ¶
func (ts *TimeSeriesStorage) AggregateRange(ctx context.Context, query TimeAggregationQuery) (*TimeAggregationResult, error)
AggregateRange aggregates time series data over time windows
func (*TimeSeriesStorage) Clear ¶
func (ts *TimeSeriesStorage) Clear(ctx context.Context) error
Clear clears all time series
func (*TimeSeriesStorage) Count ¶
func (ts *TimeSeriesStorage) Count(ctx context.Context) (int64, error)
Count returns the number of time series
func (*TimeSeriesStorage) Health ¶
func (ts *TimeSeriesStorage) Health(ctx context.Context) error
Health checks the health of the time-series storage system
func (*TimeSeriesStorage) List ¶
func (ts *TimeSeriesStorage) List(ctx context.Context, filters map[string]string) ([]*MetricEntry, error)
List lists all time series matching filters
func (*TimeSeriesStorage) QueryRange ¶
func (ts *TimeSeriesStorage) QueryRange(ctx context.Context, query TimeRangeQuery) (*TimeRangeResult, error)
QueryRange queries time series data within a time range
func (*TimeSeriesStorage) Retrieve ¶
func (ts *TimeSeriesStorage) Retrieve(ctx context.Context, name string, tags map[string]string) (*MetricEntry, error)
Retrieve retrieves a metric entry (latest point) from time-series
func (*TimeSeriesStorage) SetLogger ¶
func (ts *TimeSeriesStorage) SetLogger(logger logger.Logger)
SetLogger sets the logger for the time-series storage
func (*TimeSeriesStorage) Start ¶
func (ts *TimeSeriesStorage) Start(ctx context.Context) error
Start starts the time-series storage system
func (*TimeSeriesStorage) Stats ¶
func (ts *TimeSeriesStorage) Stats(ctx context.Context) (interface{}, error)
Stats returns storage statistics
func (*TimeSeriesStorage) Stop ¶
func (ts *TimeSeriesStorage) Stop(ctx context.Context) error
Stop stops the time-series storage system
func (*TimeSeriesStorage) Store ¶
func (ts *TimeSeriesStorage) Store(ctx context.Context, entry *MetricEntry) error
Store stores a metric entry as a time-series point
type TimeSeriesStorageConfig ¶
type TimeSeriesStorageConfig struct {
Retention time.Duration `yaml:"retention" json:"retention"`
Resolution time.Duration `yaml:"resolution" json:"resolution"`
MaxSeries int `yaml:"max_series" json:"max_series"`
MaxPointsPerSeries int `yaml:"max_points_per_series" json:"max_points_per_series"`
CompressionEnabled bool `yaml:"compression_enabled" json:"compression_enabled"`
CompressionDelay time.Duration `yaml:"compression_delay" json:"compression_delay"`
CleanupInterval time.Duration `yaml:"cleanup_interval" json:"cleanup_interval"`
EnableStats bool `yaml:"enable_stats" json:"enable_stats"`
}
TimeSeriesStorageConfig contains configuration for time-series storage
func DefaultTimeSeriesStorageConfig ¶
func DefaultTimeSeriesStorageConfig() *TimeSeriesStorageConfig
DefaultTimeSeriesStorageConfig returns default configuration
type TimeSeriesStorageStats ¶
type TimeSeriesStorageStats struct {
SeriesCount int64 `json:"series_count"`
TotalPoints int64 `json:"total_points"`
CompressedPoints int64 `json:"compressed_points"`
TotalWrites int64 `json:"total_writes"`
TotalReads int64 `json:"total_reads"`
TotalDeletes int64 `json:"total_deletes"`
CompressionRuns int64 `json:"compression_runs"`
CleanupRuns int64 `json:"cleanup_runs"`
LastCleanup time.Time `json:"last_cleanup"`
LastCompression time.Time `json:"last_compression"`
AverageSeriesSize float64 `json:"average_series_size"`
OldestPoint time.Time `json:"oldest_point"`
NewestPoint time.Time `json:"newest_point"`
CompressionRatio float64 `json:"compression_ratio"`
MemoryUsage int64 `json:"memory_usage"`
Uptime time.Duration `json:"uptime"`
// contains filtered or unexported fields
}
TimeSeriesStorageStats contains statistics about time-series storage
type TimeWindow ¶
type TimeWindow struct {
Start time.Time `json:"start"`
End time.Time `json:"end"`
Count int64 `json:"count"`
Sum float64 `json:"sum"`
Min float64 `json:"min"`
Max float64 `json:"max"`
Mean float64 `json:"mean"`
StdDev float64 `json:"stddev"`
Compressed bool `json:"compressed"`
}
TimeWindow represents aggregated data for a time window