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
5 changes: 5 additions & 0 deletions internal/controller/telemetry/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ type Data struct {
ControlPlanePodCount int64
// NginxOneConnectionEnabled is a boolean that indicates whether the connection to the Nginx One Console is enabled.
NginxOneConnectionEnabled bool
// InferencePoolCount is the number of InferencePools that are referenced by at least one Route.
InferencePoolCount int64
}

// NGFResourceCounts stores the counts of all relevant resources that NGF processes and generates configuration from.
Expand Down Expand Up @@ -174,6 +176,8 @@ func (c DataCollectorImpl) Collect(ctx context.Context) (Data, error) {

nginxPodCount := getNginxPodCount(g, clusterInfo.NodeCount)

inferencePoolCount := int64(len(g.ReferencedInferencePools))

data := Data{
Data: tel.Data{
ProjectName: "NGF",
Expand All @@ -194,6 +198,7 @@ func (c DataCollectorImpl) Collect(ctx context.Context) (Data, error) {
NginxPodCount: nginxPodCount,
ControlPlanePodCount: int64(replicaCount),
NginxOneConnectionEnabled: c.cfg.NginxOneConsoleConnection,
InferencePoolCount: inferencePoolCount,
}

return data, nil
Expand Down
11 changes: 11 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 @@ -520,6 +525,8 @@ var _ = Describe("Collector", Ordered, func() {
expData.ControlPlanePodCount = int64(2)
expData.NginxOneConnectionEnabled = true

expData.InferencePoolCount = 3

data, err := dataCollector.Collect(ctx)
Expect(err).ToNot(HaveOccurred())

Expand Down Expand Up @@ -700,6 +707,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 @@ -783,6 +793,7 @@ var _ = Describe("Collector", Ordered, func() {
BackendTLSPolicyCount: 1,
}
expData.NginxPodCount = 1
expData.InferencePoolCount = 1

data, err := dataCollector.Collect(ctx)

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 @@ -114,5 +114,8 @@ attached at the Gateway level. */
/** NginxOneConnectionEnabled is a boolean that indicates whether the connection to the Nginx One Console is enabled. */
boolean? NginxOneConnectionEnabled = null;

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

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func (d *Data) Attributes() []attribute.KeyValue {
attrs = append(attrs, attribute.Int64("NginxPodCount", d.NginxPodCount))
attrs = append(attrs, attribute.Int64("ControlPlanePodCount", d.ControlPlanePodCount))
attrs = append(attrs, attribute.Bool("NginxOneConnectionEnabled", d.NginxOneConnectionEnabled))
attrs = append(attrs, attribute.Int64("InferencePoolCount", d.InferencePoolCount))

return attrs
}
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 @@ -47,6 +47,7 @@ func TestDataAttributes(t *testing.T) {
NginxPodCount: 3,
ControlPlanePodCount: 3,
NginxOneConnectionEnabled: true,
InferencePoolCount: 16,
}

expected := []attribute.KeyValue{
Expand Down Expand Up @@ -86,6 +87,7 @@ func TestDataAttributes(t *testing.T) {
attribute.Int64("NginxPodCount", 3),
attribute.Int64("ControlPlanePodCount", 3),
attribute.Bool("NginxOneConnectionEnabled", true),
attribute.Int64("InferencePoolCount", 16),
}

result := data.Attributes()
Expand Down Expand Up @@ -132,6 +134,7 @@ func TestDataAttributesWithEmptyData(t *testing.T) {
attribute.Int64("NginxPodCount", 0),
attribute.Int64("ControlPlanePodCount", 0),
attribute.Bool("NginxOneConnectionEnabled", false),
attribute.Int64("InferencePoolCount", 0),
}

result := data.Attributes()
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 @@ -96,6 +96,7 @@ var _ = Describe("Telemetry test with OTel collector", Label("telemetry"), func(
"NginxPodCount: Int(0)",
"ControlPlanePodCount: Int(1)",
"NginxOneConnectionEnabled: Bool(false)",
"InferencePoolCount: Int(0)",
},
)
})
Expand Down
Loading