Documentation
¶
Overview ¶
internal/utils/crypto.go
internal/utils/logger.go
internal/utils/metrics.go
Index ¶
- func Decrypt(ciphertext, key string) (string, error)
- func Encrypt(plaintext, key string) (string, error)
- func GenerateSecureKey(length int) ([]byte, error)
- func InitLogger(logFile string) error
- type APIMetrics
- func (am *APIMetrics) RecordAPIRequest(endpoint, method string, statusCode int, duration time.Duration)
- func (am *APIMetrics) RecordError(errorType, component string)
- func (am *APIMetrics) RecordLLMRequest(provider, model string, tokensUsed int, duration time.Duration)
- func (am *APIMetrics) RecordSceneInteraction(sceneID, interactionType string)
- func (am *APIMetrics) RecordUserAction(userID, action string)
- func (am *APIMetrics) StartMetricsCollection(ctx context.Context)
- type Counter
- type Gauge
- type Histogram
- type LogEntry
- type LogLevel
- type Logger
- func (l *Logger) Debug(message string, fields map[string]interface{})
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Enable(enabled bool)
- func (l *Logger) Error(message string, fields map[string]interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Fatal(message string, fields map[string]interface{})
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Info(message string, fields map[string]interface{})
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) SetLogLevel(level LogLevel)
- func (l *Logger) Warn(message string, fields map[string]interface{})
- func (l *Logger) Warnf(format string, args ...interface{})
- type MetricsCollector
- func (m *MetricsCollector) AddCounter(name string, value int64)
- func (m *MetricsCollector) DecGauge(name string)
- func (m *MetricsCollector) GetCounterValue(name string) int64
- func (m *MetricsCollector) GetGauge(name string) int64
- func (m *MetricsCollector) GetMetrics() map[string]interface{}
- func (m *MetricsCollector) IncGauge(name string)
- func (m *MetricsCollector) IncrementCounter(name string)
- func (m *MetricsCollector) RecordHistogram(name string, value int64)
- func (m *MetricsCollector) SetGauge(name string, value int64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateSecureKey ¶ added in v1.3.1
GenerateSecureKey generates a cryptographically secure random key of specified length
func InitLogger ¶
InitLogger initializes the logger with a log file
Types ¶
type APIMetrics ¶
type APIMetrics struct {
// contains filtered or unexported fields
}
APIMetrics represents API-specific metrics
func NewAPIMetrics ¶
func NewAPIMetrics() *APIMetrics
NewAPIMetrics creates a new API metrics instance
func (*APIMetrics) RecordAPIRequest ¶
func (am *APIMetrics) RecordAPIRequest(endpoint, method string, statusCode int, duration time.Duration)
RecordAPIRequest records metrics for an API request
func (*APIMetrics) RecordError ¶
func (am *APIMetrics) RecordError(errorType, component string)
RecordError records an error metric
func (*APIMetrics) RecordLLMRequest ¶
func (am *APIMetrics) RecordLLMRequest(provider, model string, tokensUsed int, duration time.Duration)
RecordLLMRequest records metrics for an LLM request
func (*APIMetrics) RecordSceneInteraction ¶
func (am *APIMetrics) RecordSceneInteraction(sceneID, interactionType string)
RecordSceneInteraction records metrics for a scene interaction
func (*APIMetrics) RecordUserAction ¶
func (am *APIMetrics) RecordUserAction(userID, action string)
RecordUserAction records metrics for a user action
func (*APIMetrics) StartMetricsCollection ¶
func (am *APIMetrics) StartMetricsCollection(ctx context.Context)
StartMetricsCollection starts background metrics collection
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
Histogram metric (simple implementation tracking count, sum, min, max)
type LogEntry ¶
type LogEntry struct {
Level string `json:"level"`
Timestamp time.Time `json:"timestamp"`
Message string `json:"message"`
File string `json:"file"`
Line int `json:"line"`
Func string `json:"func"`
Fields map[string]interface{} `json:"fields,omitempty"`
}
LogEntry represents a log entry
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents a structured logger
func (*Logger) SetLogLevel ¶
SetLogLevel sets the minimum level for logging
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
MetricsCollector collects application metrics
func GetMetricsCollector ¶
func GetMetricsCollector() *MetricsCollector
GetMetricsCollector returns the global metrics collector
func (*MetricsCollector) AddCounter ¶
func (m *MetricsCollector) AddCounter(name string, value int64)
AddCounter adds a value to a counter metric
func (*MetricsCollector) DecGauge ¶
func (m *MetricsCollector) DecGauge(name string)
DecGauge decrements a gauge metric
func (*MetricsCollector) GetCounterValue ¶
func (m *MetricsCollector) GetCounterValue(name string) int64
GetCounterValue gets the current value of a counter
func (*MetricsCollector) GetGauge ¶
func (m *MetricsCollector) GetGauge(name string) int64
GetGauge gets the current value of a gauge
func (*MetricsCollector) GetMetrics ¶
func (m *MetricsCollector) GetMetrics() map[string]interface{}
GetMetrics returns a snapshot of all metrics
func (*MetricsCollector) IncGauge ¶
func (m *MetricsCollector) IncGauge(name string)
IncGauge increments a gauge metric
func (*MetricsCollector) IncrementCounter ¶
func (m *MetricsCollector) IncrementCounter(name string)
IncrementCounter increments a counter metric
func (*MetricsCollector) RecordHistogram ¶
func (m *MetricsCollector) RecordHistogram(name string, value int64)
RecordHistogram records a value in a histogram
func (*MetricsCollector) SetGauge ¶
func (m *MetricsCollector) SetGauge(name string, value int64)
SetGauge sets a gauge metric