Skip to content

Commit 5865dc5

Browse files
committed
Add telemetry collection for referenced inference pools
1 parent 75998ba commit 5865dc5

File tree

6 files changed

+22
-1
lines changed

6 files changed

+22
-1
lines changed

internal/controller/telemetry/collector.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ type NGFResourceCounts struct {
105105
UpstreamSettingsPolicyCount int64
106106
// GatewayAttachedNpCount is the total number of NginxProxy resources that are attached to a Gateway.
107107
GatewayAttachedNpCount int64
108+
// InferencePoolCount is the number of InferencePools that are referenced by at least one Route.
109+
InferencePoolCount int64
108110
}
109111

110112
// DataCollectorConfig holds configuration parameters for DataCollectorImpl.
@@ -265,6 +267,8 @@ func collectGraphResourceCount(
265267

266268
ngfResourceCounts.GatewayAttachedNpCount = gatewayAttachedNPCount
267269

270+
ngfResourceCounts.InferencePoolCount = int64(len(g.ReferencedInferencePools))
271+
268272
return ngfResourceCounts
269273
}
270274

internal/controller/telemetry/collector_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,11 @@ var _ = Describe("Collector", Ordered, func() {
417417
},
418418
},
419419
},
420+
ReferencedInferencePools: map[types.NamespacedName]*graph.ReferencedInferencePool{
421+
{Namespace: "test", Name: "inferencePool-1"}: {},
422+
{Namespace: "test", Name: "inferencePool-2"}: {},
423+
{Namespace: "test", Name: "inferencePool-3"}: {},
424+
},
420425
}
421426

422427
configs := []*dataplane.Configuration{
@@ -487,6 +492,7 @@ var _ = Describe("Collector", Ordered, func() {
487492
SnippetsFilterCount: 3,
488493
UpstreamSettingsPolicyCount: 1,
489494
GatewayAttachedNpCount: 2,
495+
InferencePoolCount: 3,
490496
}
491497
expData.ClusterVersion = "1.29.2"
492498
expData.ClusterPlatform = "kind"
@@ -700,6 +706,9 @@ var _ = Describe("Collector", Ordered, func() {
700706
BackendTLSPolicies: map[types.NamespacedName]*graph.BackendTLSPolicy{
701707
{Namespace: "test", Name: "BackendTLSPolicy-1"}: {},
702708
},
709+
ReferencedInferencePools: map[types.NamespacedName]*graph.ReferencedInferencePool{
710+
{Namespace: "test", Name: "inferencePool-1"}: {},
711+
},
703712
}
704713

705714
config1 = []*dataplane.Configuration{
@@ -781,6 +790,7 @@ var _ = Describe("Collector", Ordered, func() {
781790
UpstreamSettingsPolicyCount: 1,
782791
GatewayAttachedNpCount: 1,
783792
BackendTLSPolicyCount: 1,
793+
InferencePoolCount: 1,
784794
}
785795
expData.NginxPodCount = 1
786796

internal/controller/telemetry/data.avdl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ attached at the Gateway level. */
105105
/** GatewayAttachedNpCount is the total number of NginxProxy resources that are attached to a Gateway. */
106106
long? GatewayAttachedNpCount = null;
107107

108+
/** InferencePoolCount is the number of InferencePools that are referenced by at least one Route. */
109+
long? InferencePoolCount = null;
110+
108111
/** NginxPodCount is the total number of Nginx data plane Pods. */
109112
long? NginxPodCount = null;
110113

internal/controller/telemetry/data_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func TestDataAttributes(t *testing.T) {
4141
SnippetsFilterCount: 13,
4242
UpstreamSettingsPolicyCount: 14,
4343
GatewayAttachedNpCount: 15,
44+
InferencePoolCount: 16,
4445
},
4546
SnippetsFiltersDirectives: []string{"main-three-count", "http-two-count", "server-one-count"},
4647
SnippetsFiltersDirectivesCount: []int64{3, 2, 1},
@@ -83,6 +84,7 @@ func TestDataAttributes(t *testing.T) {
8384
attribute.Int64("SnippetsFilterCount", 13),
8485
attribute.Int64("UpstreamSettingsPolicyCount", 14),
8586
attribute.Int64("GatewayAttachedNpCount", 15),
87+
attribute.Int64("InferencePoolCount", 16),
8688
attribute.Int64("NginxPodCount", 3),
8789
attribute.Int64("ControlPlanePodCount", 3),
8890
attribute.Bool("NginxOneConnectionEnabled", true),
@@ -129,6 +131,7 @@ func TestDataAttributesWithEmptyData(t *testing.T) {
129131
attribute.Int64("SnippetsFilterCount", 0),
130132
attribute.Int64("UpstreamSettingsPolicyCount", 0),
131133
attribute.Int64("GatewayAttachedNpCount", 0),
134+
attribute.Int64("InferencePoolCount", 0),
132135
attribute.Int64("NginxPodCount", 0),
133136
attribute.Int64("ControlPlanePodCount", 0),
134137
attribute.Bool("NginxOneConnectionEnabled", false),
@@ -137,6 +140,5 @@ func TestDataAttributesWithEmptyData(t *testing.T) {
137140
result := data.Attributes()
138141

139142
g := NewWithT(t)
140-
141143
g.Expect(result).To(Equal(expected))
142144
}

internal/controller/telemetry/ngfresourcecounts_attributes_generated.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func (d *NGFResourceCounts) Attributes() []attribute.KeyValue {
2828
attrs = append(attrs, attribute.Int64("SnippetsFilterCount", d.SnippetsFilterCount))
2929
attrs = append(attrs, attribute.Int64("UpstreamSettingsPolicyCount", d.UpstreamSettingsPolicyCount))
3030
attrs = append(attrs, attribute.Int64("GatewayAttachedNpCount", d.GatewayAttachedNpCount))
31+
attrs = append(attrs, attribute.Int64("InferencePoolCount", d.InferencePoolCount))
3132

3233
return attrs
3334
}

tests/suite/telemetry_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ var _ = Describe("Telemetry test with OTel collector", Label("telemetry"), func(
9696
"NginxPodCount: Int(0)",
9797
"ControlPlanePodCount: Int(1)",
9898
"NginxOneConnectionEnabled: Bool(false)",
99+
"InferencePoolCount: Int(0)",
99100
},
100101
)
101102
})

0 commit comments

Comments
 (0)