logging

package
v0.2.4 Latest Latest
Warning

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

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

Documentation

Overview

internal/logging/aggregator.go

internal/logging/metrics.go

internal/logging/rotation.go

Index

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) Stop

func (a *Aggregator) Stop()

Stop stops all log collectors

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 LogLevel

type LogLevel string

LogLevel represents log severity level

const (
	LogLevelDebug LogLevel = "debug"
	LogLevelInfo  LogLevel = "info"
	LogLevelWarn  LogLevel = "warn"
	LogLevelError LogLevel = "error"
)

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) Close

func (rw *RotatingWriter) Close() error

Close closes the log file

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

type Throughput

type Throughput struct {
	RequestsPerSecond float64 `json:"requests_per_second"`
	BytesPerSecond    float64 `json:"bytes_per_second"`
	TotalRequests     uint64  `json:"total_requests"`
	TotalBytes        uint64  `json:"total_bytes"`
}

Throughput represents request throughput

Jump to

Keyboard shortcuts

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