layer1: add namespace source counts
This commit is contained in:
@@ -124,6 +124,7 @@ func LogNamespaceManagerSummary(logger *zap.Logger, message string, summary Name
|
||||
logger.Info(message,
|
||||
zap.Int("total_namespaces", summary.TotalNamespaces),
|
||||
zap.Any("phase_counts", summary.PhaseCounts),
|
||||
zap.Any("source_counts", summary.SourceCounts),
|
||||
zap.Strings("subscribers", summary.Subscribers),
|
||||
)
|
||||
}
|
||||
@@ -258,10 +259,12 @@ func (m *inMemoryNamespaceManager) Summary() NamespaceManagerSummary {
|
||||
summary := NamespaceManagerSummary{
|
||||
TotalNamespaces: len(records),
|
||||
PhaseCounts: make(map[NamespacePhase]int),
|
||||
SourceCounts: make(map[NamespaceSource]int),
|
||||
Subscribers: m.SnapshotSubscribers(),
|
||||
}
|
||||
for _, record := range records {
|
||||
summary.PhaseCounts[record.Phase]++
|
||||
summary.SourceCounts[record.Source]++
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ type NamespaceEvent struct {
|
||||
type NamespaceManagerSummary struct {
|
||||
TotalNamespaces int
|
||||
PhaseCounts map[NamespacePhase]int
|
||||
SourceCounts map[NamespaceSource]int
|
||||
Subscribers []string
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,9 @@ func TestNamespaceManagerSnapshotAndGet(t *testing.T) {
|
||||
if summary.TotalNamespaces != 2 {
|
||||
t.Fatalf("expected summary total namespaces to be 2, got %d", summary.TotalNamespaces)
|
||||
}
|
||||
if summary.SourceCounts[NamespaceSourceWatcher] != 2 {
|
||||
t.Fatalf("expected watcher source count to be 2")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNamespaceManagerUpsertIncrementsGeneration(t *testing.T) {
|
||||
@@ -473,6 +476,9 @@ func TestNamespaceManagerSummary(t *testing.T) {
|
||||
if !reflect.DeepEqual([]string{"router"}, summary.Subscribers) {
|
||||
t.Fatalf("expected router subscriber in summary")
|
||||
}
|
||||
if summary.SourceCounts[NamespaceSourceWatcher] != 2 {
|
||||
t.Fatalf("expected two watcher-sourced namespaces")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLogNamespaceManagerSummaryWithNilLogger(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user