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:
@@ -59,8 +59,42 @@ var (
|
||||
Name: "build_info",
|
||||
Help: "Build metadata (value always 1).",
|
||||
}, []string{"version", "git_sha"})
|
||||
|
||||
prefixAggregationDuration = promauto.NewHistogram(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Name: "prefix_aggregation_duration_seconds",
|
||||
Help: "Time spent in smartAggregatePrefixRows during tenant render.",
|
||||
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 16),
|
||||
})
|
||||
|
||||
prefixAggregationRawCount = promauto.NewHistogram(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Name: "prefix_aggregation_raw_count",
|
||||
Help: "Prefix row count before CIDR aggregation on tenant render.",
|
||||
Buckets: prometheus.ExponentialBuckets(1, 2, 16),
|
||||
})
|
||||
|
||||
prefixAggregationAggregatedCount = promauto.NewHistogram(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Name: "prefix_aggregation_aggregated_count",
|
||||
Help: "Prefix row count after CIDR aggregation on tenant render.",
|
||||
Buckets: prometheus.ExponentialBuckets(1, 2, 16),
|
||||
})
|
||||
)
|
||||
|
||||
// RecordPrefixAggregation records tenant render CIDR aggregation stats.
|
||||
func RecordPrefixAggregation(rawCount, aggregatedCount int, duration time.Duration) {
|
||||
if rawCount < 0 {
|
||||
rawCount = 0
|
||||
}
|
||||
if aggregatedCount < 0 {
|
||||
aggregatedCount = 0
|
||||
}
|
||||
prefixAggregationDuration.Observe(duration.Seconds())
|
||||
prefixAggregationRawCount.Observe(float64(rawCount))
|
||||
prefixAggregationAggregatedCount.Observe(float64(aggregatedCount))
|
||||
}
|
||||
|
||||
// RecordJobTerminal increments jobs_finished_total for terminal statuses.
|
||||
func RecordJobTerminal(kind, status string) {
|
||||
switch status {
|
||||
|
||||
Reference in New Issue
Block a user