metrics

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultReaderMaxLineBytes = 1 << 20
	DefaultReaderMaxBytes     = 64 << 20
	DefaultReaderMaxEvents    = 100_000
)
View Source
const SchemaVersion = "dbrain.metrics.v1"

Variables

This section is empty.

Functions

func DurationMillis

func DurationMillis(d time.Duration) int64

func ErrorObject

func ErrorObject(err any) map[string]any

func NewRunID

func NewRunID(prefix string, now time.Time) string

func SubjectHash

func SubjectHash(kind string, key string) string

Types

type AuditStatusCounts added in v0.7.0

type AuditStatusCounts struct {
	Pass, Warn, Fail, Unknown, Skipped int
}

type Config

type Config struct {
	Enabled            bool
	Path               string
	Detail             Detail
	IncludeSubjectKeys bool
	Strict             bool
}

func ResolveConfig

func ResolveConfig(rootDir string, logDir string) (Config, error)

type DailyArrival added in v0.7.0

type DailyArrival struct {
	Day       string `json:"day"`
	Created   int    `json:"created"`
	Updated   int    `json:"updated"`
	Unchanged int    `json:"unchanged"`
	Skipped   int    `json:"skipped"`
	Linked    int    `json:"linked"`
	Blocked   int    `json:"blocked"`
	Failed    int    `json:"failed"`
}

type Detail

type Detail string
const (
	DetailStage     Detail = "stage"
	DetailItem      Detail = "item"
	DetailModelCall Detail = "model_call"
)

type Event

type Event map[string]any

func AuditRunCompletedEvent added in v0.7.0

func AuditRunCompletedEvent(profile, status string, duration time.Duration, counts AuditStatusCounts) Event

func SQLiteArchiveAttemptEvent added in v0.7.0

func SQLiteArchiveAttemptEvent() Event

func SQLiteArchiveCompletedEvent added in v0.7.0

func SQLiteArchiveCompletedEvent(duration time.Duration, snapshotBytes int64, archiveBytes int64) Event

func SQLiteArchiveFailedEvent added in v0.7.0

func SQLiteArchiveFailedEvent(duration time.Duration, code SQLiteArchiveFailureCode) Event

func SQLiteArchiveIntervalSkippedEvent added in v0.7.0

func SQLiteArchiveIntervalSkippedEvent(remaining time.Duration) Event

func SQLiteArchiveLockSkippedEvent added in v0.7.0

func SQLiteArchiveLockSkippedEvent() Event

func SQLiteArchiveOverlapSkippedEvent added in v0.7.0

func SQLiteArchiveOverlapSkippedEvent() Event

func SQLiteArchiveStartedEvent added in v0.7.0

func SQLiteArchiveStartedEvent() Event

func (Event) WithSubject

func (e Event) WithSubject(kind string, key string, includeKey bool) Event

type ImportRecord added in v0.7.0

type ImportRecord struct {
	AttemptedAt   time.Time
	SucceededAt   time.Time
	LastArrivalAt time.Time
	AttemptCount  int
	SuccessCount  int
	FailureCount  int
	Daily         []DailyArrival
}

type Marker added in v0.7.0

type Marker struct {
	Event              string
	At                 time.Time
	ExplainsContinuity bool
}

type Reader added in v0.7.0

type Reader struct {
	Path         string
	MaxLineBytes int
	MaxBytes     int64
	MaxEvents    int
	BlockBytes   int
}

func NewReader added in v0.7.0

func NewReader(path string) *Reader

func (*Reader) Read added in v0.7.0

func (r *Reader) Read(ctx context.Context, start time.Time) (Window, error)

type RunContext

type RunContext struct {
	RunID      string
	Command    string
	Invocation string
	Sink       Sink
}

func (RunContext) Detail

func (ctx RunContext) Detail() Detail

func (RunContext) Emit

func (ctx RunContext) Emit(event Event) error

func (RunContext) Enabled

func (ctx RunContext) Enabled() bool

func (RunContext) IncludeSubjectKeys

func (ctx RunContext) IncludeSubjectKeys() bool

type RunRecord added in v0.7.0

type RunRecord struct {
	ID                   string
	Invocation           string
	StartedAt            time.Time
	CompletedAt          time.Time
	Status               string
	SelectedStages       []string
	CompletedStages      map[string]StageRecord
	Duration             time.Duration
	RecordComplete       bool
	ToleratedStageErrors int
}

type SQLiteArchiveFailureCode added in v0.7.0

type SQLiteArchiveFailureCode string
const (
	SQLiteArchiveFailureArchive  SQLiteArchiveFailureCode = "archive_failed"
	SQLiteArchiveFailureCanceled SQLiteArchiveFailureCode = "canceled"
	SQLiteArchiveFailureLock     SQLiteArchiveFailureCode = "lock_failed"
	SQLiteArchiveFailureState    SQLiteArchiveFailureCode = "state_failed"
	SQLiteArchiveFailureTimeout  SQLiteArchiveFailureCode = "timeout"
)

type Sink

type Sink interface {
	Enabled() bool
	Detail() Detail
	IncludeSubjectKeys() bool
	Emit(Event) error
	Close() error
}

func NoopSink

func NoopSink() Sink

func Open

func Open(cfg Config) (Sink, error)

type StageRecord added in v0.7.0

type StageRecord struct {
	Status      string
	CompletedAt time.Time
	Duration    time.Duration
}

type Window added in v0.7.0

type Window struct {
	CoverageStart          time.Time
	CoverageEnd            time.Time
	Runs                   []RunRecord
	Imports                map[string]ImportRecord
	Markers                []Marker
	DurationSamples        []time.Duration
	ParseErrorCount        int
	ParseErrorPositions    []int64
	BytesRead              int64
	EventsRead             int
	ByteBudgetExhausted    bool
	EventBudgetExhausted   bool
	AttemptCount           int
	CompletedCount         int
	LatestAttemptPresent   bool
	LatestCompletedPresent bool
}

func (Window) String added in v0.7.0

func (w Window) String() string

Jump to

Keyboard shortcuts

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