Documentation
¶
Overview ¶
Package observability records handler events, audits and basic runtime metrics.
Index ¶
- Constants
- Variables
- func AppendAudit(audits AuditLogStore, actor, action, target string, metadata map[string]any)
- func Middleware(eventLogs EventLogStore, metrics MetricsStore) middleware.Middleware
- type AuditDispatcher
- type AuditDispatcherStats
- type AuditLogEntry
- type AuditLogQuery
- type AuditLogStore
- type EventLogEntry
- type EventLogQuery
- type EventLogStore
- type InMemory
- func (m *InMemory) AppendAudit(ctx context.Context, entry AuditLogEntry) error
- func (m *InMemory) AppendEvent(ctx context.Context, entry EventLogEntry) error
- func (m *InMemory) ListAudit(ctx context.Context, query AuditLogQuery) ([]AuditLogEntry, error)
- func (m *InMemory) ListEvents(ctx context.Context, query EventLogQuery) ([]EventLogEntry, error)
- func (m *InMemory) Observe(duration time.Duration, hasError bool, at time.Time)
- func (m *InMemory) Snapshot(ctx context.Context) (MetricsSnapshot, error)
- type MetricsSnapshot
- type MetricsStore
- type Postgres
- func (p *Postgres) AppendAudit(ctx context.Context, entry AuditLogEntry) error
- func (p *Postgres) AppendEvent(ctx context.Context, entry EventLogEntry) error
- func (p *Postgres) EnsureSchema(ctx context.Context) error
- func (p *Postgres) ListAudit(ctx context.Context, query AuditLogQuery) ([]AuditLogEntry, error)
- func (p *Postgres) ListEvents(ctx context.Context, query EventLogQuery) ([]EventLogEntry, error)
- func (p *Postgres) Observe(duration time.Duration, hasError bool, at time.Time)
- func (p *Postgres) Snapshot(ctx context.Context) (MetricsSnapshot, error)
Constants ¶
View Source
const ( DefaultAuditQueueSize = 256 DefaultAuditTimeout = 2 * time.Second )
Variables ¶
View Source
var ( ErrAuditDropped = errors.New("audit event dropped") ErrInvalidAudit = errors.New("invalid audit event") )
Functions ¶
func AppendAudit ¶
func AppendAudit(audits AuditLogStore, actor, action, target string, metadata map[string]any)
func Middleware ¶
func Middleware(eventLogs EventLogStore, metrics MetricsStore) middleware.Middleware
Types ¶
type AuditDispatcher ¶ added in v2.0.1
type AuditDispatcher struct {
// contains filtered or unexported fields
}
AuditDispatcher keeps audit persistence outside mutation and Control paths. Its queue and store calls are bounded; audit remains non-authoritative.
func NewAuditDispatcher ¶ added in v2.0.1
func NewAuditDispatcher(store AuditLogStore, queueSize int, timeout time.Duration) (*AuditDispatcher, error)
func (*AuditDispatcher) Append ¶ added in v2.0.1
func (d *AuditDispatcher) Append(entry AuditLogEntry) error
func (*AuditDispatcher) Close ¶ added in v2.0.1
func (d *AuditDispatcher) Close(ctx context.Context) error
func (*AuditDispatcher) Stats ¶ added in v2.0.1
func (d *AuditDispatcher) Stats() AuditDispatcherStats
type AuditDispatcherStats ¶ added in v2.0.1
type AuditLogEntry ¶
type AuditLogQuery ¶
type AuditLogStore ¶
type AuditLogStore interface {
AppendAudit(ctx context.Context, entry AuditLogEntry) error
ListAudit(ctx context.Context, query AuditLogQuery) ([]AuditLogEntry, error)
}
type EventLogEntry ¶
type EventLogEntry struct {
ID string `json:"id"`
Platform string `json:"platform"`
Type string `json:"type"`
ChatID string `json:"chat_id"`
UserID string `json:"user_id"`
Text string `json:"text,omitempty"`
Command string `json:"command,omitempty"`
Payload string `json:"payload,omitempty"`
Error string `json:"error,omitempty"`
DurationMS int64 `json:"duration_ms"`
CreatedAt time.Time `json:"created_at"`
}
type EventLogQuery ¶
type EventLogStore ¶
type EventLogStore interface {
AppendEvent(ctx context.Context, entry EventLogEntry) error
ListEvents(ctx context.Context, query EventLogQuery) ([]EventLogEntry, error)
}
type InMemory ¶
type InMemory struct {
// contains filtered or unexported fields
}
func NewInMemory ¶
func (*InMemory) AppendAudit ¶
func (m *InMemory) AppendAudit(ctx context.Context, entry AuditLogEntry) error
func (*InMemory) AppendEvent ¶
func (m *InMemory) AppendEvent(ctx context.Context, entry EventLogEntry) error
func (*InMemory) ListAudit ¶
func (m *InMemory) ListAudit(ctx context.Context, query AuditLogQuery) ([]AuditLogEntry, error)
func (*InMemory) ListEvents ¶
func (m *InMemory) ListEvents(ctx context.Context, query EventLogQuery) ([]EventLogEntry, error)
type MetricsSnapshot ¶
type MetricsStore ¶
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
func NewPostgres ¶
func (*Postgres) AppendAudit ¶
func (p *Postgres) AppendAudit(ctx context.Context, entry AuditLogEntry) error
func (*Postgres) AppendEvent ¶
func (p *Postgres) AppendEvent(ctx context.Context, entry EventLogEntry) error
func (*Postgres) ListAudit ¶
func (p *Postgres) ListAudit(ctx context.Context, query AuditLogQuery) ([]AuditLogEntry, error)
func (*Postgres) ListEvents ¶
func (p *Postgres) ListEvents(ctx context.Context, query EventLogQuery) ([]EventLogEntry, error)
Click to show internal directories.
Click to hide internal directories.