Documentation
¶
Overview ¶
internal/logging/aggregator.go
internal/logging/metrics.go
internal/logging/rotation.go
Index ¶
- func CalculatePerformanceStats(metrics *ServiceMetrics) map[string]interface{}
- func CollectAIMetrics(ctx context.Context, metrics *PerformanceMetrics)
- func CollectCacheMetrics(ctx context.Context, metrics *PerformanceMetrics)
- func CollectDatabaseMetrics(ctx context.Context, metrics *PerformanceMetrics)
- func StartHTTPCollector(port int, metrics *PerformanceMetrics)
- type Aggregator
- type LogEntry
- type LogLevel
- type LogOptions
- type MetricsStorage
- type PerformanceMetrics
- func (pm *PerformanceMetrics) GetAllMetrics() map[string]*ServiceMetrics
- func (pm *PerformanceMetrics) GetMetrics(service string) (*ServiceMetrics, bool)
- func (pm *PerformanceMetrics) RecordResponseTime(service, endpoint, method string, duration time.Duration, success bool)
- func (pm *PerformanceMetrics) SetCustomMetric(service, key string, value interface{})
- func (pm *PerformanceMetrics) UpdateThroughput(service string, requests, bytes uint64)
- type ResponseTime
- type RotatingWriter
- type ServiceMetrics
- type Throughput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculatePerformanceStats ¶
func CalculatePerformanceStats(metrics *ServiceMetrics) map[string]interface{}
CalculatePerformanceStats calculates performance statistics
func CollectAIMetrics ¶
func CollectAIMetrics(ctx context.Context, metrics *PerformanceMetrics)
AI Service specific metrics
func CollectCacheMetrics ¶
func CollectCacheMetrics(ctx context.Context, metrics *PerformanceMetrics)
Cache Service specific metrics
func CollectDatabaseMetrics ¶
func CollectDatabaseMetrics(ctx context.Context, metrics *PerformanceMetrics)
Database Service specific metrics
func StartHTTPCollector ¶
func StartHTTPCollector(port int, metrics *PerformanceMetrics)
StartHTTPCollector starts an HTTP metrics collector for the AI service
Types ¶
type Aggregator ¶
type Aggregator struct {
// contains filtered or unexported fields
}
Aggregator manages log collection from all containers
func NewAggregator ¶
func NewAggregator(cfg *config.Config) (*Aggregator, error)
NewAggregator creates a new log aggregator
func (*Aggregator) GetLogs ¶
func (a *Aggregator) GetLogs(options LogOptions) ([]LogEntry, error)
GetLogs retrieves logs with filters
func (*Aggregator) Start ¶
func (a *Aggregator) Start(ctx context.Context) error
Start begins log collection from all containers
func (*Aggregator) StreamLogs ¶
func (a *Aggregator) StreamLogs(ctx context.Context, options LogOptions, output chan<- LogEntry) error
StreamLogs streams logs in real-time
type LogEntry ¶
type LogEntry struct {
Timestamp time.Time `json:"timestamp"`
Service string `json:"service"`
Container string `json:"container"`
Level LogLevel `json:"level"`
Message string `json:"message"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Source string `json:"source"` // stdout or stderr
ContainerID string `json:"container_id,omitempty"`
}
LogEntry represents a structured log entry
type LogOptions ¶
type LogOptions struct {
Service string
Level string
Since time.Time
Tail int
Follow bool
Search string
}
LogOptions represents log filtering options
type MetricsStorage ¶
type MetricsStorage struct {
// contains filtered or unexported fields
}
MetricsStorage handles persistent storage of metrics
func NewMetricsStorage ¶
func NewMetricsStorage(dir string) (*MetricsStorage, error)
NewMetricsStorage creates a new metrics storage
func (*MetricsStorage) Write ¶
func (ms *MetricsStorage) Write(metrics *ServiceMetrics) error
Write writes metrics to storage
type PerformanceMetrics ¶
type PerformanceMetrics struct {
// contains filtered or unexported fields
}
PerformanceMetrics tracks service performance metrics
func NewPerformanceMetrics ¶
func NewPerformanceMetrics() (*PerformanceMetrics, error)
NewPerformanceMetrics creates a new performance metrics tracker
func (*PerformanceMetrics) GetAllMetrics ¶
func (pm *PerformanceMetrics) GetAllMetrics() map[string]*ServiceMetrics
GetAllMetrics returns metrics for all services
func (*PerformanceMetrics) GetMetrics ¶
func (pm *PerformanceMetrics) GetMetrics(service string) (*ServiceMetrics, bool)
GetMetrics returns current metrics for a service
func (*PerformanceMetrics) RecordResponseTime ¶
func (pm *PerformanceMetrics) RecordResponseTime(service, endpoint, method string, duration time.Duration, success bool)
RecordResponseTime records an API response time
func (*PerformanceMetrics) SetCustomMetric ¶
func (pm *PerformanceMetrics) SetCustomMetric(service, key string, value interface{})
SetCustomMetric sets a custom metric value
func (*PerformanceMetrics) UpdateThroughput ¶
func (pm *PerformanceMetrics) UpdateThroughput(service string, requests, bytes uint64)
UpdateThroughput updates throughput metrics
type ResponseTime ¶
type ResponseTime struct {
Endpoint string `json:"endpoint"`
Method string `json:"method"`
Duration time.Duration `json:"duration"`
Timestamp time.Time `json:"timestamp"`
Success bool `json:"success"`
}
ResponseTime tracks API response times
type RotatingWriter ¶
type RotatingWriter struct {
// contains filtered or unexported fields
}
RotatingWriter handles log file rotation
func NewRotatingWriter ¶
func NewRotatingWriter(path string, maxSize int64) (*RotatingWriter, error)
NewRotatingWriter creates a new rotating log writer
func (*RotatingWriter) Write ¶
func (rw *RotatingWriter) Write(p []byte) (n int, err error)
Write writes data to the log file
func (*RotatingWriter) WriteJSON ¶
func (rw *RotatingWriter) WriteJSON(v interface{}) error
WriteJSON writes a JSON object to the log
type ServiceMetrics ¶
type ServiceMetrics struct {
Service string `json:"service"`
ResponseTimes []ResponseTime `json:"response_times,omitempty"`
Throughput Throughput `json:"throughput"`
ErrorRate float64 `json:"error_rate"`
Custom map[string]interface{} `json:"custom,omitempty"`
LastUpdated time.Time `json:"last_updated"`
}
ServiceMetrics represents metrics for a specific service