Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/controller/telemetry/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ type NGFResourceCounts struct {
UpstreamSettingsPolicyCount int64
// GatewayAttachedNpCount is the total number of NginxProxy resources that are attached to a Gateway.
GatewayAttachedNpCount int64
// InferencePoolCount is the number of InferencePools that are referenced by at least one Route.
InferencePoolCount int64
}

// DataCollectorConfig holds configuration parameters for DataCollectorImpl.
Expand Down Expand Up @@ -265,6 +267,8 @@ func collectGraphResourceCount(

ngfResourceCounts.GatewayAttachedNpCount = gatewayAttachedNPCount

ngfResourceCounts.InferencePoolCount = int64(len(g.ReferencedInferencePools))

return ngfResourceCounts
}

Expand Down
10 changes: 10 additions & 0 deletions internal/controller/telemetry/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,11 @@ var _ = Describe("Collector", Ordered, func() {
},
},
},
ReferencedInferencePools: map[types.NamespacedName]*graph.ReferencedInferencePool{
{Namespace: "test", Name: "inferencePool-1"}: {},
{Namespace: "test", Name: "inferencePool-2"}: {},
{Namespace: "test", Name: "inferencePool-3"}: {},
},
}

configs := []*dataplane.Configuration{
Expand Down Expand Up @@ -487,6 +492,7 @@ var _ = Describe("Collector", Ordered, func() {
SnippetsFilterCount: 3,
UpstreamSettingsPolicyCount: 1,
GatewayAttachedNpCount: 2,
InferencePoolCount: 3,
}
expData.ClusterVersion = "1.29.2"
expData.ClusterPlatform = "kind"
Expand Down Expand Up @@ -700,6 +706,9 @@ var _ = Describe("Collector", Ordered, func() {
BackendTLSPolicies: map[types.NamespacedName]*graph.BackendTLSPolicy{
{Namespace: "test", Name: "BackendTLSPolicy-1"}: {},
},
ReferencedInferencePools: map[types.NamespacedName]*graph.ReferencedInferencePool{
{Namespace: "test", Name: "inferencePool-1"}: {},
},
}

config1 = []*dataplane.Configuration{
Expand Down Expand Up @@ -781,6 +790,7 @@ var _ = Describe("Collector", Ordered, func() {
UpstreamSettingsPolicyCount: 1,
GatewayAttachedNpCount: 1,
BackendTLSPolicyCount: 1,
InferencePoolCount: 1,
}
expData.NginxPodCount = 1

Expand Down
3 changes: 3 additions & 0 deletions internal/controller/telemetry/data.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ attached at the Gateway level. */
/** GatewayAttachedNpCount is the total number of NginxProxy resources that are attached to a Gateway. */
long? GatewayAttachedNpCount = null;

/** InferencePoolCount is the number of InferencePools that are referenced by at least one Route. */
long? InferencePoolCount = null;

/** NginxPodCount is the total number of Nginx data plane Pods. */
long? NginxPodCount = null;

Expand Down
3 changes: 3 additions & 0 deletions internal/controller/telemetry/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestDataAttributes(t *testing.T) {
SnippetsFilterCount: 13,
UpstreamSettingsPolicyCount: 14,
GatewayAttachedNpCount: 15,
InferencePoolCount: 16,
},
SnippetsFiltersDirectives: []string{"main-three-count", "http-two-count", "server-one-count"},
SnippetsFiltersDirectivesCount: []int64{3, 2, 1},
Expand Down Expand Up @@ -83,6 +84,7 @@ func TestDataAttributes(t *testing.T) {
attribute.Int64("SnippetsFilterCount", 13),
attribute.Int64("UpstreamSettingsPolicyCount", 14),
attribute.Int64("GatewayAttachedNpCount", 15),
attribute.Int64("InferencePoolCount", 16),
attribute.Int64("NginxPodCount", 3),
attribute.Int64("ControlPlanePodCount", 3),
attribute.Bool("NginxOneConnectionEnabled", true),
Expand Down Expand Up @@ -129,6 +131,7 @@ func TestDataAttributesWithEmptyData(t *testing.T) {
attribute.Int64("SnippetsFilterCount", 0),
attribute.Int64("UpstreamSettingsPolicyCount", 0),
attribute.Int64("GatewayAttachedNpCount", 0),
attribute.Int64("InferencePoolCount", 0),
attribute.Int64("NginxPodCount", 0),
attribute.Int64("ControlPlanePodCount", 0),
attribute.Bool("NginxOneConnectionEnabled", false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func (d *NGFResourceCounts) Attributes() []attribute.KeyValue {
attrs = append(attrs, attribute.Int64("SnippetsFilterCount", d.SnippetsFilterCount))
attrs = append(attrs, attribute.Int64("UpstreamSettingsPolicyCount", d.UpstreamSettingsPolicyCount))
attrs = append(attrs, attribute.Int64("GatewayAttachedNpCount", d.GatewayAttachedNpCount))
attrs = append(attrs, attribute.Int64("InferencePoolCount", d.InferencePoolCount))

return attrs
}
Expand Down
1 change: 1 addition & 0 deletions tests/suite/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ var _ = Describe("Telemetry test with OTel collector", Label("telemetry"), func(
"SnippetsFilterCount: Int(0)",
"UpstreamSettingsPolicyCount: Int(0)",
"GatewayAttachedNpCount: Int(0)",
"InferencePoolCount: Int(0)",
"NginxPodCount: Int(0)",
"ControlPlanePodCount: Int(1)",
"NginxOneConnectionEnabled: Bool(false)",
Expand Down
Loading