diff --git a/internal/mode/static/telemetry/collector.go b/internal/mode/static/telemetry/collector.go index 477eaef731..a3c5cee399 100644 --- a/internal/mode/static/telemetry/collector.go +++ b/internal/mode/static/telemetry/collector.go @@ -67,6 +67,10 @@ type NGFResourceCounts struct { ServiceCount int64 // EndpointCount include the total count of Endpoints(IP:port) across all referenced services. EndpointCount int64 + // GRPCRouteCount is the number of relevant GRPCRoutes. + GRPCRouteCount int64 + // BackendTLSPolicyCount is the number of relevant BackendTLSPolicies. + BackendTLSPolicyCount int64 } // DataCollectorConfig holds configuration parameters for DataCollectorImpl. @@ -174,7 +178,7 @@ func collectGraphResourceCount( ngfResourceCounts.GatewayCount++ } - ngfResourceCounts.HTTPRouteCount = computeRouteCount(g.Routes) + ngfResourceCounts.HTTPRouteCount, ngfResourceCounts.GRPCRouteCount = computeRouteCount(g.Routes) ngfResourceCounts.SecretCount = int64(len(g.ReferencedSecrets)) ngfResourceCounts.ServiceCount = int64(len(g.ReferencedServices)) @@ -184,16 +188,21 @@ func collectGraphResourceCount( } } + ngfResourceCounts.BackendTLSPolicyCount = int64(len(g.BackendTLSPolicies)) + return ngfResourceCounts, nil } -func computeRouteCount(routes map[graph.RouteKey]*graph.L7Route) (httpRouteCount int64) { +func computeRouteCount(routes map[graph.RouteKey]*graph.L7Route) (httpRouteCount, grpcRouteCount int64) { for _, r := range routes { if r.RouteType == graph.RouteTypeHTTP { httpRouteCount = httpRouteCount + 1 } + if r.RouteType == graph.RouteTypeGRPC { + grpcRouteCount = grpcRouteCount + 1 + } } - return httpRouteCount + return httpRouteCount, grpcRouteCount } func getPodReplicaSet( diff --git a/internal/mode/static/telemetry/collector_test.go b/internal/mode/static/telemetry/collector_test.go index 35475c0394..599ed516d2 100644 --- a/internal/mode/static/telemetry/collector_test.go +++ b/internal/mode/static/telemetry/collector_test.go @@ -283,6 +283,7 @@ var _ = Describe("Collector", Ordered, func() { {NamespacedName: types.NamespacedName{Namespace: "test", Name: "hr-2"}}: {RouteType: graph.RouteTypeHTTP}, {NamespacedName: types.NamespacedName{Namespace: "test", Name: "hr-3"}}: {RouteType: graph.RouteTypeHTTP}, {NamespacedName: types.NamespacedName{Namespace: "test", Name: "gr-1"}}: {RouteType: graph.RouteTypeGRPC}, + {NamespacedName: types.NamespacedName{Namespace: "test", Name: "gr-2"}}: {RouteType: graph.RouteTypeGRPC}, }, ReferencedSecrets: map[types.NamespacedName]*graph.Secret{ client.ObjectKeyFromObject(secret1): { @@ -298,6 +299,11 @@ var _ = Describe("Collector", Ordered, func() { client.ObjectKeyFromObject(svc2): {}, client.ObjectKeyFromObject(nilsvc): {}, }, + BackendTLSPolicies: map[types.NamespacedName]*graph.BackendTLSPolicy{ + {Namespace: "test", Name: "backendTLSPolicy-1"}: {}, + {Namespace: "test", Name: "backendTLSPolicy-2"}: {}, + {Namespace: "test", Name: "backendTLSPolicy-3"}: {}, + }, } config := &dataplane.Configuration{ @@ -336,12 +342,14 @@ var _ = Describe("Collector", Ordered, func() { expData.ClusterNodeCount = 3 expData.NGFResourceCounts = telemetry.NGFResourceCounts{ - GatewayCount: 3, - GatewayClassCount: 3, - HTTPRouteCount: 3, - SecretCount: 3, - ServiceCount: 3, - EndpointCount: 4, + GatewayCount: 3, + GatewayClassCount: 3, + HTTPRouteCount: 3, + SecretCount: 3, + ServiceCount: 3, + EndpointCount: 4, + GRPCRouteCount: 2, + BackendTLSPolicyCount: 3, } expData.ClusterVersion = "1.29.2" expData.ClusterPlatform = "kind" @@ -567,12 +575,14 @@ var _ = Describe("Collector", Ordered, func() { fakeGraphGetter.GetLatestGraphReturns(&graph.Graph{}) fakeConfigurationGetter.GetLatestConfigurationReturns(invalidUpstreamsConfig) expData.NGFResourceCounts = telemetry.NGFResourceCounts{ - GatewayCount: 0, - GatewayClassCount: 0, - HTTPRouteCount: 0, - SecretCount: 0, - ServiceCount: 0, - EndpointCount: 0, + GatewayCount: 0, + GatewayClassCount: 0, + HTTPRouteCount: 0, + SecretCount: 0, + ServiceCount: 0, + EndpointCount: 0, + GRPCRouteCount: 0, + BackendTLSPolicyCount: 0, } data, err := dataCollector.Collect(ctx) diff --git a/internal/mode/static/telemetry/data.avdl b/internal/mode/static/telemetry/data.avdl index 2077d28779..68880f3b4c 100644 --- a/internal/mode/static/telemetry/data.avdl +++ b/internal/mode/static/telemetry/data.avdl @@ -62,6 +62,12 @@ Each value is either 'true' or 'false' for boolean flags and 'default' or 'user- /** EndpointCount include the total count of Endpoints(IP:port) across all referenced services. */ long? EndpointCount = null; + /** GRPCRouteCount is the number of relevant GRPCRoutes. */ + long? GRPCRouteCount = null; + + /** BackendTLSPolicyCount is the number of relevant BackendTLSPolicies. */ + long? BackendTLSPolicyCount = null; + /** NGFReplicaCount is the number of replicas of the NGF Pod. */ long? NGFReplicaCount = null; diff --git a/internal/mode/static/telemetry/data_test.go b/internal/mode/static/telemetry/data_test.go index b18ce17cb9..a8285fc8f2 100644 --- a/internal/mode/static/telemetry/data_test.go +++ b/internal/mode/static/telemetry/data_test.go @@ -24,12 +24,14 @@ func TestDataAttributes(t *testing.T) { FlagNames: []string{"test-flag"}, FlagValues: []string{"test-value"}, NGFResourceCounts: NGFResourceCounts{ - GatewayCount: 1, - GatewayClassCount: 2, - HTTPRouteCount: 3, - SecretCount: 4, - ServiceCount: 5, - EndpointCount: 6, + GatewayCount: 1, + GatewayClassCount: 2, + HTTPRouteCount: 3, + SecretCount: 4, + ServiceCount: 5, + EndpointCount: 6, + GRPCRouteCount: 7, + BackendTLSPolicyCount: 8, }, NGFReplicaCount: 3, } @@ -53,13 +55,14 @@ func TestDataAttributes(t *testing.T) { attribute.Int64("SecretCount", 4), attribute.Int64("ServiceCount", 5), attribute.Int64("EndpointCount", 6), + attribute.Int64("GRPCRouteCount", 7), + attribute.Int64("BackendTLSPolicyCount", 8), attribute.Int64("NGFReplicaCount", 3), } result := data.Attributes() g := NewWithT(t) - g.Expect(result).To(Equal(expected)) } @@ -85,6 +88,8 @@ func TestDataAttributesWithEmptyData(t *testing.T) { attribute.Int64("SecretCount", 0), attribute.Int64("ServiceCount", 0), attribute.Int64("EndpointCount", 0), + attribute.Int64("GRPCRouteCount", 0), + attribute.Int64("BackendTLSPolicyCount", 0), attribute.Int64("NGFReplicaCount", 0), } diff --git a/internal/mode/static/telemetry/ngfresourcecounts_attributes_generated.go b/internal/mode/static/telemetry/ngfresourcecounts_attributes_generated.go index 19fa4ae744..f32dc40c06 100644 --- a/internal/mode/static/telemetry/ngfresourcecounts_attributes_generated.go +++ b/internal/mode/static/telemetry/ngfresourcecounts_attributes_generated.go @@ -21,6 +21,8 @@ func (d *NGFResourceCounts) Attributes() []attribute.KeyValue { attrs = append(attrs, attribute.Int64("SecretCount", d.SecretCount)) attrs = append(attrs, attribute.Int64("ServiceCount", d.ServiceCount)) attrs = append(attrs, attribute.Int64("EndpointCount", d.EndpointCount)) + attrs = append(attrs, attribute.Int64("GRPCRouteCount", d.GRPCRouteCount)) + attrs = append(attrs, attribute.Int64("BackendTLSPolicyCount", d.BackendTLSPolicyCount)) return attrs diff --git a/site/content/overview/product-telemetry.md b/site/content/overview/product-telemetry.md index 8db9f360c9..97c161579d 100644 --- a/site/content/overview/product-telemetry.md +++ b/site/content/overview/product-telemetry.md @@ -26,7 +26,7 @@ Telemetry data is collected once every 24 hours and sent to a service managed by - **Deployment Replica Count:** the count of NGINX Gateway Fabric Pods. - **Image Build Source:** whether the image was built by GitHub or locally (values are `gha`, `local`, or `unknown`). The source repository of the images is **not** collected. - **Deployment Flags:** a list of NGINX Gateway Fabric Deployment flags that are specified by a user. The actual values of non-boolean flags are **not** collected; we only record that they are either `true` or `false` for boolean flags and `default` or `user-defined` for the rest. -- **Count of Resources:** the total count of resources related to NGINX Gateway Fabric. This includes `GatewayClasses`, `Gateways`, `HTTPRoutes`, `Secrets`, `Services`, and `Endpoints`. The data within these resources is **not** collected. +- **Count of Resources:** the total count of resources related to NGINX Gateway Fabric. This includes `GatewayClasses`, `Gateways`, `HTTPRoutes`,`GRPCRoutes`, `Secrets`, `Services`, `BackendTLSPolicies`, and `Endpoints`. The data within these resources is **not** collected. This data is used to identify the following information: diff --git a/tests/suite/telemetry_test.go b/tests/suite/telemetry_test.go index dab0fca191..ec6cbf0999 100644 --- a/tests/suite/telemetry_test.go +++ b/tests/suite/telemetry_test.go @@ -95,6 +95,8 @@ var _ = Describe("Telemetry test with OTel collector", Label("telemetry"), func( "SecretCount: Int(0)", "ServiceCount: Int(0)", "EndpointCount: Int(0)", + "GRPCRouteCount: Int(0)", + "BackendTLSPolicyCount: Int(0)", "NGFReplicaCount: Int(1)", }, )