Documentation
¶
Index ¶
- Constants
- func DiscoveryRunDir(workspaceDir, runID string) string
- func DiscoveryRunRecordPath(workspaceDir, runID string) string
- func DiscoveryRunsDir(workspaceDir string) string
- func ImportRunDir(workspaceDir, runID string) string
- func ImportRunRecordPath(workspaceDir, runID string) string
- func ImportRunsDir(workspaceDir string) string
- func ListLogFiles(dir string) ([]string, error)
- func ReadAllLogs(dir string) (map[string][]string, error)
- func WriteDiscoveryRunRecord(workspaceDir string, record DiscoveryRunRecord) error
- func WriteImportRunRecord(workspaceDir string, record ImportRunRecord) error
- type Builder
- type DiscoveryConfig
- type DiscoveryLabelBatchProgress
- type DiscoveryResult
- type DiscoveryRunError
- type DiscoveryRunProgress
- type DiscoveryRunRecord
- func LatestDiscoveryRun(records []DiscoveryRunRecord) *DiscoveryRunRecord
- func LatestSuccessfulDiscoveryRun(records []DiscoveryRunRecord) *DiscoveryRunRecord
- func ListDiscoveryRunRecords(workspaceDir string) ([]DiscoveryRunRecord, error)
- func ReadDiscoveryRunRecord(workspaceDir, runID string) (DiscoveryRunRecord, error)
- type DiscoveryRunState
- type DiscoveryStep
- type ImportConfig
- type ImportFetchResult
- type ImportFetcher
- type ImportLineWriter
- type ImportRequest
- type ImportResult
- type ImportRunError
- type ImportRunRecord
- type ImportRunState
- type LineRef
- type PatternInfo
- type PatternLabeler
- type TaggedLine
Constants ¶
const DiscoveryRunsDirName = "discovery-runs"
const ImportRunsDirName = "import-runs"
Variables ¶
This section is empty.
Functions ¶
func DiscoveryRunDir ¶
func DiscoveryRunRecordPath ¶
func DiscoveryRunsDir ¶
func ImportRunDir ¶
func ImportRunRecordPath ¶
func ImportRunsDir ¶
func ListLogFiles ¶
ListLogFiles returns the basenames of all files in <dir>/logs/.
func ReadAllLogs ¶
ReadAllLogs reads all log files in <dir>/logs/ and returns a map of filename to lines.
func WriteDiscoveryRunRecord ¶
func WriteDiscoveryRunRecord(workspaceDir string, record DiscoveryRunRecord) error
func WriteImportRunRecord ¶
func WriteImportRunRecord(workspaceDir string, record ImportRunRecord) error
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder creates the structured workspace directory from pre-processed data.
func NewBuilder ¶
func NewBuilder(dir string, taggedLines []TaggedLine, templates []pattern.DrainCluster, labels []semantic.SemanticLabel) *Builder
NewBuilder creates a Builder with pre-processed data.
func (*Builder) Patterns ¶
func (b *Builder) Patterns() []PatternInfo
Patterns returns the pattern results computed during BuildAll.
func (*Builder) Unmatched ¶
func (b *Builder) Unmatched() []TaggedLine
Unmatched returns log lines that did not match any generated pattern.
type DiscoveryConfig ¶
type DiscoveryLabelBatchProgress ¶
type DiscoveryLabelBatchProgress struct {
Event string `json:"event,omitempty"`
BatchNumber int `json:"batch_number"`
BatchCount int `json:"batch_count"`
BatchSize int `json:"batch_size"`
Attempt int `json:"attempt"`
MaxAttempts int `json:"max_attempts"`
CompletedCount int `json:"completed_count"`
}
type DiscoveryResult ¶
type DiscoveryResult struct {
FileCount int
LineCount int
PatternCount int
UnmatchedCount int
RunID string
}
DiscoveryResult summarizes a completed discovery run.
func Discover ¶
func Discover(ctx context.Context, config DiscoveryConfig) (DiscoveryResult, error)
Discover starts a DiscoveryRun and writes generated results under discovery-runs/<run-id>/.
type DiscoveryRunError ¶
type DiscoveryRunError struct {
Code string `json:"code"`
Message string `json:"message"`
Step DiscoveryStep `json:"step,omitempty"`
}
type DiscoveryRunProgress ¶
type DiscoveryRunProgress struct {
Step DiscoveryStep `json:"step,omitempty"`
LabelBatch *DiscoveryLabelBatchProgress `json:"label_batch,omitempty"`
}
type DiscoveryRunRecord ¶
type DiscoveryRunRecord struct {
ID string `json:"id"`
State DiscoveryRunState `json:"state"`
CurrentStep DiscoveryStep `json:"current_step,omitempty"`
ProgressMessage string `json:"progress_message,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
Progress *DiscoveryRunProgress `json:"progress,omitempty"`
Error *DiscoveryRunError `json:"error,omitempty"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
LogFileCount int `json:"log_file_count"`
LineCount int `json:"line_count"`
PatternCount int `json:"pattern_count"`
UnmatchedCount int `json:"unmatched_count"`
Patterns []PatternInfo `json:"patterns,omitempty"`
Unmatched []TaggedLine `json:"unmatched,omitempty"`
}
func LatestDiscoveryRun ¶
func LatestDiscoveryRun(records []DiscoveryRunRecord) *DiscoveryRunRecord
func LatestSuccessfulDiscoveryRun ¶
func LatestSuccessfulDiscoveryRun(records []DiscoveryRunRecord) *DiscoveryRunRecord
func ListDiscoveryRunRecords ¶
func ListDiscoveryRunRecords(workspaceDir string) ([]DiscoveryRunRecord, error)
func ReadDiscoveryRunRecord ¶
func ReadDiscoveryRunRecord(workspaceDir, runID string) (DiscoveryRunRecord, error)
type DiscoveryRunState ¶
type DiscoveryRunState string
const ( DiscoveryRunStateQueued DiscoveryRunState = "QUEUED" DiscoveryRunStateRunning DiscoveryRunState = "RUNNING" DiscoveryRunStateSucceeded DiscoveryRunState = "SUCCEEDED" DiscoveryRunStateFailed DiscoveryRunState = "FAILED" )
type DiscoveryStep ¶
type DiscoveryStep string
const ( DiscoveryStepReadingLogs DiscoveryStep = "READING_LOGS" DiscoveryStepMergingEntries DiscoveryStep = "MERGING_ENTRIES" DiscoveryStepDiscoveringPatterns DiscoveryStep = "DISCOVERING_PATTERNS" DiscoveryStepLabelingPatterns DiscoveryStep = "LABELING_PATTERNS" DiscoveryStepWritingResults DiscoveryStep = "WRITING_RESULTS" )
type ImportConfig ¶
type ImportFetchResult ¶
type ImportFetchResult struct {
Truncated bool
}
ImportFetchResult reports facts about one completed provider fetch.
type ImportFetcher ¶
type ImportFetcher func( ctx context.Context, req ImportRequest, writeLine ImportLineWriter, ) (ImportFetchResult, error)
ImportFetcher pulls matching entries from a provider. It is the narrow seam between run orchestration and provider network access, so tests can inject a fake without touching the network (precedent: DiscoveryConfig.Labeler).
type ImportLineWriter ¶
ImportLineWriter writes one envelope NDJSON line without a trailing newline.
type ImportRequest ¶
ImportRequest is what the fetcher needs to pull entries from a provider.
type ImportResult ¶
ImportResult summarizes a completed import run.
func RunImport ¶
func RunImport(ctx context.Context, config ImportConfig) (ImportResult, error)
RunImport starts an ImportRun: it records provenance under import-runs/<run-id>/record.json, pulls entries through the fetcher, and lands them as one NDJSON log file. It never starts discovery (ADR 0005). Zero matching entries is a success with no log file written.
type ImportRunError ¶
type ImportRunRecord ¶
type ImportRunRecord struct {
ID string `json:"id"`
Provider string `json:"provider"`
Project string `json:"project"`
Filter string `json:"filter,omitempty"`
From time.Time `json:"from"`
To time.Time `json:"to"`
Limit int `json:"limit"`
State ImportRunState `json:"state"`
EntryCount int `json:"entry_count"`
Truncated bool `json:"truncated"`
LogFileName string `json:"log_file_name,omitempty"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
Error *ImportRunError `json:"error,omitempty"`
}
ImportRunRecord is the persisted provenance for one provider import. These records are the only store of import history (ADR 0004). Provider metadata such as labels, trace, and resource belongs here, never in the imported log lines.
func ListImportRunRecords ¶
func ListImportRunRecords(workspaceDir string) ([]ImportRunRecord, error)
func ReadImportRunRecord ¶
func ReadImportRunRecord(workspaceDir, runID string) (ImportRunRecord, error)
type ImportRunState ¶
type ImportRunState string
const ( ImportRunStateQueued ImportRunState = "QUEUED" ImportRunStateRunning ImportRunState = "RUNNING" ImportRunStateSucceeded ImportRunState = "SUCCEEDED" ImportRunStateFailed ImportRunState = "FAILED" )
type PatternInfo ¶
type PatternInfo struct {
SemanticID string
DirName string
Template string
Description string
Count int
FirstSeen LineRef
LastSeen LineRef
LineRefs []LineRef
Samples []string
}
PatternInfo holds all data about a discovered pattern for workspace output.
type PatternLabeler ¶
type PatternLabeler func(context.Context, semantic.Config, []semantic.PatternInput) ([]semantic.SemanticLabel, error)
PatternLabeler assigns stable semantic labels to discovered Drain patterns.
type TaggedLine ¶
type TaggedLine struct {
Content string
FileName string
LineNum int
// ExtractedLine is the text fed to pattern mining for NDJSON entries.
// Empty for plain text entries, whose Content is mined directly.
ExtractedLine string `json:",omitempty"`
}
TaggedLine represents a log line with its source file and line number.
func (TaggedLine) DrainLine ¶
func (t TaggedLine) DrainLine() string
DrainLine returns the text used for pattern mining and template matching: the extracted line for NDJSON entries, otherwise the raw content.