feat: enhance observability with prefix aggregation metrics
CI / changes (push) Successful in 7s
CI / openapi (push) Has been skipped
CI / go (push) Successful in 33s
CI / docker-web (push) Has been skipped
CI / docker-bird (push) Has been skipped
CI / bird2 (push) Successful in 16s
CI / docker-go (push) Successful in 8m30s
CI / changes (push) Successful in 7s
CI / openapi (push) Has been skipped
CI / go (push) Successful in 33s
CI / docker-web (push) Has been skipped
CI / docker-bird (push) Has been skipped
CI / bird2 (push) Successful in 16s
CI / docker-go (push) Successful in 8m30s
- Added new histograms to track prefix aggregation duration, raw count, and aggregated count during tenant rendering. - Implemented `RecordPrefixAggregation` function to record metrics for aggregation performance. - Updated `RenderTenantRevision` and `RenderTenantRevisionFromPrefixes` functions to log aggregation statistics. - Refactored `smartAggregatePrefixRows` to support both IPv4 and IPv6 aggregation, improving overall prefix handling.
This commit is contained in:
@@ -327,13 +327,22 @@ func (m *Memory) CreateRenderRevision(revisionID, tenantID, moduleID string, par
|
||||
frag[k] = v
|
||||
}
|
||||
parent := parentRevisionID
|
||||
createdAt := time.Now().UTC()
|
||||
for _, r := range m.revisions {
|
||||
if r == nil || r.TenantID != tenantID {
|
||||
continue
|
||||
}
|
||||
if !r.CreatedAt.Before(createdAt) {
|
||||
createdAt = r.CreatedAt.Add(time.Microsecond)
|
||||
}
|
||||
}
|
||||
m.revisions[revisionID] = &Revision{
|
||||
ID: revisionID,
|
||||
TenantID: tenantID,
|
||||
ModuleID: moduleID,
|
||||
ContentHash: contentHash,
|
||||
ParentRevisionID: parent,
|
||||
CreatedAt: time.Now().UTC(),
|
||||
CreatedAt: createdAt,
|
||||
MaterializedPrefixCount: len(prefixes),
|
||||
PreviewFragments: frag,
|
||||
}
|
||||
@@ -657,6 +666,9 @@ func (m *Memory) ListRevisions(tenantID, moduleID string, cursor string, limit i
|
||||
all = append(all, r)
|
||||
}
|
||||
sort.Slice(all, func(i, j int) bool {
|
||||
if all[i].CreatedAt.Equal(all[j].CreatedAt) {
|
||||
return all[i].ID > all[j].ID
|
||||
}
|
||||
return all[i].CreatedAt.After(all[j].CreatedAt)
|
||||
})
|
||||
off := 0
|
||||
|
||||
Reference in New Issue
Block a user