feat(go): chain retained snapshot artifacts
This commit is contained in:
parent
fd2bbba0d7
commit
1ab4add205
7 changed files with 278 additions and 16 deletions
|
|
@ -16,6 +16,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"codeberg.org/anassaeneroi/enodia-sentinal/go-agent/internal/assurance"
|
||||
"codeberg.org/anassaeneroi/enodia-sentinal/go-agent/internal/correlation"
|
||||
"codeberg.org/anassaeneroi/enodia-sentinal/go-agent/internal/enrich"
|
||||
"codeberg.org/anassaeneroi/enodia-sentinal/go-agent/internal/incident"
|
||||
|
|
@ -64,6 +65,7 @@ type Store struct {
|
|||
ParentOf func(int) int
|
||||
Incidents *incident.Store
|
||||
LineageDepth int
|
||||
Assurance *assurance.Chain
|
||||
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
|
@ -102,6 +104,10 @@ func New(dir, procRoot string, maxCount, maxAgeDays int) (*Store, error) {
|
|||
store := &Store{Dir: dir, ProcRoot: procRoot, MaxCount: maxCount, MaxAgeDays: maxAgeDays, Now: time.Now, LineageDepth: 8}
|
||||
store.Collect = func(pid int) ProcessDetail { return collectProcess(procRoot, pid) }
|
||||
store.ParentOf = func(pid int) int { return readParent(procRoot, pid) }
|
||||
store.Assurance, err = assurance.New(dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := store.Prune(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -183,6 +189,14 @@ func (s *Store) CaptureEvent(event map[string]any) (string, error) {
|
|||
if err := writeAtomic(base+".log", []byte(formatText(report))); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if s.Assurance != nil {
|
||||
if _, err := s.Assurance.Append("snapshot-log", base+".log", captured); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if _, err := s.Assurance.Append("snapshot-json", jsonPath, captured); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
if err := s.pruneLocked(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue