diff --git a/internal/mode/static/telemetry/collector.go b/internal/mode/static/telemetry/collector.go index 6dccd0562e..64973da90e 100644 --- a/internal/mode/static/telemetry/collector.go +++ b/internal/mode/static/telemetry/collector.go @@ -62,6 +62,8 @@ type NGFResourceCounts struct { GatewayClassCount int64 // HTTPRouteCount is the number of relevant HTTPRoutes. HTTPRouteCount int64 + // TLSRouteCount is the number of relevant TLSRoutes. + TLSRouteCount int64 // SecretCount is the number of relevant Secrets. SecretCount int64 // ServiceCount is the number of relevant Services. @@ -188,7 +190,11 @@ func collectGraphResourceCount( ngfResourceCounts.GatewayCount++ } - ngfResourceCounts.HTTPRouteCount, ngfResourceCounts.GRPCRouteCount = computeRouteCount(g.Routes) + routeCounts := computeRouteCount(g.Routes, g.L4Routes) + ngfResourceCounts.HTTPRouteCount = routeCounts.HTTPRouteCount + ngfResourceCounts.GRPCRouteCount = routeCounts.GRPCRouteCount + ngfResourceCounts.TLSRouteCount = routeCounts.TLSRouteCount + ngfResourceCounts.SecretCount = int64(len(g.ReferencedSecrets)) ngfResourceCounts.ServiceCount = int64(len(g.ReferencedServices)) @@ -224,7 +230,19 @@ func collectGraphResourceCount( return ngfResourceCounts, nil } -func computeRouteCount(routes map[graph.RouteKey]*graph.L7Route) (httpRouteCount, grpcRouteCount int64) { +type RouteCounts struct { + HTTPRouteCount int64 + GRPCRouteCount int64 + TLSRouteCount int64 +} + +func computeRouteCount( + routes map[graph.RouteKey]*graph.L7Route, + l4routes map[graph.L4RouteKey]*graph.L4Route, +) RouteCounts { + httpRouteCount := int64(0) + grpcRouteCount := int64(0) + for _, r := range routes { if r.RouteType == graph.RouteTypeHTTP { httpRouteCount = httpRouteCount + 1 @@ -233,7 +251,12 @@ func computeRouteCount(routes map[graph.RouteKey]*graph.L7Route) (httpRouteCount grpcRouteCount = grpcRouteCount + 1 } } - return httpRouteCount, grpcRouteCount + + return RouteCounts{ + HTTPRouteCount: httpRouteCount, + GRPCRouteCount: grpcRouteCount, + TLSRouteCount: int64(len(l4routes)), + } } func getPodReplicaSet( diff --git a/internal/mode/static/telemetry/collector_test.go b/internal/mode/static/telemetry/collector_test.go index 09b14b0c54..4aa1ab99bd 100644 --- a/internal/mode/static/telemetry/collector_test.go +++ b/internal/mode/static/telemetry/collector_test.go @@ -287,6 +287,11 @@ var _ = Describe("Collector", Ordered, func() { {NamespacedName: types.NamespacedName{Namespace: "test", Name: "gr-1"}}: {RouteType: graph.RouteTypeGRPC}, {NamespacedName: types.NamespacedName{Namespace: "test", Name: "gr-2"}}: {RouteType: graph.RouteTypeGRPC}, }, + L4Routes: map[graph.L4RouteKey]*graph.L4Route{ + {NamespacedName: types.NamespacedName{Namespace: "test", Name: "tr-1"}}: {}, + {NamespacedName: types.NamespacedName{Namespace: "test", Name: "tr-2"}}: {}, + {NamespacedName: types.NamespacedName{Namespace: "test", Name: "tr-3"}}: {}, + }, ReferencedSecrets: map[types.NamespacedName]*graph.Secret{ client.ObjectKeyFromObject(secret1): { Source: secret1, @@ -366,6 +371,7 @@ var _ = Describe("Collector", Ordered, func() { GatewayCount: 3, GatewayClassCount: 3, HTTPRouteCount: 3, + TLSRouteCount: 3, SecretCount: 3, ServiceCount: 3, EndpointCount: 4, @@ -512,6 +518,9 @@ var _ = Describe("Collector", Ordered, func() { Routes: map[graph.RouteKey]*graph.L7Route{ {NamespacedName: types.NamespacedName{Namespace: "test", Name: "hr-1"}}: {RouteType: graph.RouteTypeHTTP}, }, + L4Routes: map[graph.L4RouteKey]*graph.L4Route{ + {NamespacedName: types.NamespacedName{Namespace: "test", Name: "tr-1"}}: {}, + }, ReferencedSecrets: map[types.NamespacedName]*graph.Secret{ client.ObjectKeyFromObject(secret): { Source: secret, @@ -604,6 +613,7 @@ var _ = Describe("Collector", Ordered, func() { GatewayCount: 1, GatewayClassCount: 1, HTTPRouteCount: 1, + TLSRouteCount: 1, SecretCount: 1, ServiceCount: 1, EndpointCount: 1, @@ -626,6 +636,7 @@ var _ = Describe("Collector", Ordered, func() { GatewayCount: 0, GatewayClassCount: 0, HTTPRouteCount: 0, + TLSRouteCount: 0, SecretCount: 0, ServiceCount: 0, EndpointCount: 0, diff --git a/internal/mode/static/telemetry/data.avdl b/internal/mode/static/telemetry/data.avdl index 7d32720600..ab56a4280a 100644 --- a/internal/mode/static/telemetry/data.avdl +++ b/internal/mode/static/telemetry/data.avdl @@ -53,6 +53,9 @@ Each value is either 'true' or 'false' for boolean flags and 'default' or 'user- /** HTTPRouteCount is the number of relevant HTTPRoutes. */ long? HTTPRouteCount = null; + /** TLSRouteCount is the number of relevant TLSRoutes. */ + long? TLSRouteCount = null; + /** SecretCount is the number of relevant Secrets. */ long? SecretCount = null; diff --git a/internal/mode/static/telemetry/data_test.go b/internal/mode/static/telemetry/data_test.go index cb4b09df86..62bb54f6c8 100644 --- a/internal/mode/static/telemetry/data_test.go +++ b/internal/mode/static/telemetry/data_test.go @@ -31,6 +31,7 @@ func TestDataAttributes(t *testing.T) { ServiceCount: 5, EndpointCount: 6, GRPCRouteCount: 7, + TLSRouteCount: 5, BackendTLSPolicyCount: 8, GatewayAttachedClientSettingsPolicyCount: 9, RouteAttachedClientSettingsPolicyCount: 10, @@ -56,6 +57,7 @@ func TestDataAttributes(t *testing.T) { attribute.Int64("GatewayCount", 1), attribute.Int64("GatewayClassCount", 2), attribute.Int64("HTTPRouteCount", 3), + attribute.Int64("TLSRouteCount", 5), attribute.Int64("SecretCount", 4), attribute.Int64("ServiceCount", 5), attribute.Int64("EndpointCount", 6), @@ -93,6 +95,7 @@ func TestDataAttributesWithEmptyData(t *testing.T) { attribute.Int64("GatewayCount", 0), attribute.Int64("GatewayClassCount", 0), attribute.Int64("HTTPRouteCount", 0), + attribute.Int64("TLSRouteCount", 0), attribute.Int64("SecretCount", 0), attribute.Int64("ServiceCount", 0), attribute.Int64("EndpointCount", 0), diff --git a/internal/mode/static/telemetry/ngfresourcecounts_attributes_generated.go b/internal/mode/static/telemetry/ngfresourcecounts_attributes_generated.go index 1224cb096a..ea8e793a91 100644 --- a/internal/mode/static/telemetry/ngfresourcecounts_attributes_generated.go +++ b/internal/mode/static/telemetry/ngfresourcecounts_attributes_generated.go @@ -18,6 +18,7 @@ func (d *NGFResourceCounts) Attributes() []attribute.KeyValue { attrs = append(attrs, attribute.Int64("GatewayCount", d.GatewayCount)) attrs = append(attrs, attribute.Int64("GatewayClassCount", d.GatewayClassCount)) attrs = append(attrs, attribute.Int64("HTTPRouteCount", d.HTTPRouteCount)) + attrs = append(attrs, attribute.Int64("TLSRouteCount", d.TLSRouteCount)) attrs = append(attrs, attribute.Int64("SecretCount", d.SecretCount)) attrs = append(attrs, attribute.Int64("ServiceCount", d.ServiceCount)) attrs = append(attrs, attribute.Int64("EndpointCount", d.EndpointCount)) diff --git a/site/content/overview/product-telemetry.md b/site/content/overview/product-telemetry.md index 4b222c5b6b..cb13b6997a 100644 --- a/site/content/overview/product-telemetry.md +++ b/site/content/overview/product-telemetry.md @@ -27,7 +27,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`,`GRPCRoutes`, `Secrets`, `Services`, `BackendTLSPolicies`, `ClientSettingsPolicies`, `NginxProxies`, `ObservabilityPolicies`, 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`, `TLSRoutes`, `Secrets`, `Services`, `BackendTLSPolicies`, `ClientSettingsPolicies`, `NginxProxies`, `ObservabilityPolicies`, 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 3ce1ec6669..a88cfd3ee0 100644 --- a/tests/suite/telemetry_test.go +++ b/tests/suite/telemetry_test.go @@ -75,6 +75,7 @@ var _ = Describe("Telemetry test with OTel collector", Label("telemetry"), func( "GatewayCount: Int(0)", "GatewayClassCount: Int(1)", "HTTPRouteCount: Int(0)", + "TLSRouteCount: Int(0)", "SecretCount: Int(0)", "ServiceCount: Int(0)", "EndpointCount: Int(0)",