Documentation
¶
Index ¶
- func InitTracer(ctx context.Context, serviceName string) (shutdown func(context.Context) error, err error)
- func Tracer() trace.Tracer
- type Counter
- type Gauge
- type Histogram
- type LogLevel
- type Logger
- func (l *Logger) Debug(msg string, fields map[string]interface{})
- func (l *Logger) DebugWithContext(ctx context.Context, msg string, fields map[string]interface{})
- func (l *Logger) Error(msg string, fields map[string]interface{})
- func (l *Logger) ErrorWithContext(ctx context.Context, msg string, fields map[string]interface{})
- func (l *Logger) ErrorWithStack(msg string, err error, fields map[string]interface{})
- func (l *Logger) Fatal(msg string, fields map[string]interface{})
- func (l *Logger) FatalWithContext(ctx context.Context, msg string, fields map[string]interface{})
- func (l *Logger) Info(msg string, fields map[string]interface{})
- func (l *Logger) InfoWithContext(ctx context.Context, msg string, fields map[string]interface{})
- func (l *Logger) LogCircuitBreakerState(ctx context.Context, from, to string, reason string)
- func (l *Logger) LogError(ctx context.Context, err error, operation string)
- func (l *Logger) LogRequest(ctx context.Context, method, url string, statusCode int, ...)
- func (l *Logger) LogToolExecution(ctx context.Context, toolName string, duration time.Duration, success bool)
- func (l *Logger) SetContext(ctx context.Context) map[string]string
- func (l *Logger) SetLevel(level LogLevel)
- func (l *Logger) Warn(msg string, fields map[string]interface{})
- func (l *Logger) WarnWithContext(ctx context.Context, msg string, fields map[string]interface{})
- type LoggerConfig
- type Metric
- type MetricType
- type RequestLogger
- type System
- func (m *System) Close() error
- func (m *System) GetAllMetrics() map[string]interface{}
- func (m *System) GetLogger() *Logger
- func (m *System) GetMetricsSnapshot(format string) (string, error)
- func (m *System) RecordAPIFailure(err error, duration time.Duration)
- func (m *System) RecordAPIRateLimit()
- func (m *System) RecordAPIRequest()
- func (m *System) RecordAPISuccess(duration time.Duration)
- func (m *System) RecordCacheStats(readTokens, creationTokens int)
- func (m *System) RecordCircuitBreakerStateTransition(from, to string, reason string)
- func (m *System) RecordCircuitBreakerTrip(provider string)
- func (m *System) RecordError(err error, context string)
- func (m *System) RecordQueryFailure(err error, duration time.Duration)
- func (m *System) RecordQueryIteration()
- func (m *System) RecordQuerySuccess(duration time.Duration)
- func (m *System) RecordQueryTurn()
- func (m *System) RecordToolCall(toolName string)
- func (m *System) RecordToolFailure(toolName string, err error, duration time.Duration)
- func (m *System) RecordToolPermissionDenial(toolName string)
- func (m *System) RecordToolSuccess(toolName string, duration time.Duration)
- func (m *System) ResetAllMetrics()
- func (m *System) SetCircuitBreakerState(state string)
- func (m *System) SetLogger(logger *Logger)
- func (m *System) UpdateActiveConnections(count float64)
- func (m *System) UpdateActiveSessions(count float64)
- func (m *System) UpdateMemoryUsage(mb float64)
- type Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitTracer ¶
func InitTracer(ctx context.Context, serviceName string) (shutdown func(context.Context) error, err error)
InitTracer initialises the global OTel tracer provider.
If OTEL_EXPORTER_OTLP_ENDPOINT is unset it installs a no-op provider and returns immediately — callers do not need to special-case the absence. The returned shutdown function must be called before the process exits.
By default the gRPC exporter connects without TLS (suitable for a local collector). Set OTEL_EXPORTER_OTLP_INSECURE=false to enable TLS.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a metric that only increases
func NewCounter ¶
NewCounter creates a new counter metric
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge is a metric that can go up or down
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
Histogram tracks the distribution of values
func NewHistogram ¶
NewHistogram creates a new histogram metric
func (*Histogram) Percentile ¶
Percentile calculates the approximate percentile
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents a structured logger with context
func NewLoggerWithConfig ¶
func NewLoggerWithConfig(config *LoggerConfig) *Logger
NewLoggerWithConfig creates a new logger with custom configuration
func (*Logger) DebugWithContext ¶
DebugWithContext logs a debug message with context
func (*Logger) ErrorWithContext ¶
ErrorWithContext logs an error message with context
func (*Logger) ErrorWithStack ¶
ErrorWithStack logs an error message with stack trace
func (*Logger) FatalWithContext ¶
FatalWithContext logs a fatal message with context and exits
func (*Logger) InfoWithContext ¶
InfoWithContext logs an info message with context
func (*Logger) LogCircuitBreakerState ¶
LogCircuitBreakerState logs circuit breaker state changes
func (*Logger) LogRequest ¶
func (l *Logger) LogRequest(ctx context.Context, method, url string, statusCode int, duration time.Duration)
LogRequest logs HTTP request information
func (*Logger) LogToolExecution ¶
func (l *Logger) LogToolExecution(ctx context.Context, toolName string, duration time.Duration, success bool)
LogToolExecution logs tool execution information
func (*Logger) SetContext ¶
SetContext extracts context fields from context
type LoggerConfig ¶
type LoggerConfig struct {
// Level is minimum log level to output
Level LogLevel `json:"level"`
// Output is where to write logs (stdout, stderr, file)
Output string `json:"output"`
// FilePath is file path when Output is "file"
FilePath string `json:"file_path"`
// Format is log format (json, text)
Format string `json:"format"`
// ContextFields are additional fields to include in all log entries
ContextFields []string `json:"context_fields"`
}
LoggerConfig represents logger configuration
func DefaultLoggerConfig ¶
func DefaultLoggerConfig() *LoggerConfig
DefaultLoggerConfig returns default logger configuration
type Metric ¶
type Metric struct {
// Name is the metric name
Name string `json:"name"`
// Type is the metric type
Type MetricType `json:"type"`
// Value is the metric value
Value float64 `json:"value"`
// Labels are key-value pairs for categorization
Labels map[string]string `json:"labels"`
// Timestamp is when the metric was recorded
Timestamp time.Time `json:"timestamp"`
}
Metric represents a single metric with labels
type MetricType ¶
type MetricType string
MetricType represents the type of metric
const ( MetricTypeCounter MetricType = "counter" // Counting events MetricTypeGauge MetricType = "gauge" // Point-in-time values MetricTypeHistogram MetricType = "histogram" // Distribution of values MetricTypeTimer MetricType = "timer" // Duration measurements )
type RequestLogger ¶
type RequestLogger struct {
// contains filtered or unexported fields
}
RequestLogger wraps HTTP client with logging
func NewRequestLogger ¶
func NewRequestLogger(logger *Logger) *RequestLogger
NewRequestLogger creates a new request logger
func (*RequestLogger) LogRequest ¶
func (rl *RequestLogger) LogRequest(ctx context.Context, req interface{}, resp interface{}, err error, duration time.Duration)
LogRequest logs HTTP request details
type System ¶
type System struct {
// contains filtered or unexported fields
}
System provides centralized monitoring for Seshat
func (*System) GetAllMetrics ¶
GetAllMetrics returns all current metric values
func (*System) GetMetricsSnapshot ¶
GetMetricsSnapshot returns a snapshot of all metrics in format
func (*System) RecordAPIFailure ¶
RecordAPIFailure records a failed API request
func (*System) RecordAPIRateLimit ¶
func (m *System) RecordAPIRateLimit()
RecordAPIRateLimit records a rate limit hit
func (*System) RecordAPIRequest ¶
func (m *System) RecordAPIRequest()
RecordAPIRequest records an API request
func (*System) RecordAPISuccess ¶
RecordAPISuccess records a successful API request
func (*System) RecordCacheStats ¶
RecordCacheStats records Anthropic prompt cache statistics from a response. readTokens is cache_read_input_tokens, creationTokens is cache_creation_input_tokens.
func (*System) RecordCircuitBreakerStateTransition ¶
RecordCircuitBreakerStateTransition records a state transition
func (*System) RecordCircuitBreakerTrip ¶
RecordCircuitBreakerTrip records a circuit breaker trip
func (*System) RecordError ¶
RecordError records a general error
func (*System) RecordQueryFailure ¶
RecordQueryFailure records a failed query turn
func (*System) RecordQueryIteration ¶
func (m *System) RecordQueryIteration()
RecordQueryIteration records a query loop iteration
func (*System) RecordQuerySuccess ¶
RecordQuerySuccess records a successful query turn
func (*System) RecordQueryTurn ¶
func (m *System) RecordQueryTurn()
RecordQueryTurn records a query turn
func (*System) RecordToolCall ¶
RecordToolCall records a tool call
func (*System) RecordToolFailure ¶
RecordToolFailure records a failed tool call
func (*System) RecordToolPermissionDenial ¶
RecordToolPermissionDenial records a permission denial
func (*System) RecordToolSuccess ¶
RecordToolSuccess records a successful tool call
func (*System) ResetAllMetrics ¶
func (m *System) ResetAllMetrics()
ResetAllMetrics resets all metrics to zero
func (*System) SetCircuitBreakerState ¶
SetCircuitBreakerState updates current circuit breaker state
func (*System) UpdateActiveConnections ¶
UpdateActiveConnections updates count of active connections
func (*System) UpdateActiveSessions ¶
UpdateActiveSessions updates count of active sessions
func (*System) UpdateMemoryUsage ¶
UpdateMemoryUsage updates memory usage
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer measures duration of operations
func (*Timer) Percentile ¶
Percentile returns the duration at the given percentile