@@ -71,6 +71,12 @@ type Data struct { //nolint //required to skip golangci-lint-full fieldalignment
7171 InferencePoolCount int64
7272 // BuildOS is the base operating system the control plane was built on (e.g. alpine, ubi).
7373 BuildOS string
74+ // GatewayAttachedProxySettingsPolicyCount is the number of relevant ProxySettingsPolicies
75+ // attached at the Gateway level.
76+ GatewayAttachedProxySettingsPolicyCount int64
77+ // RouteAttachedProxySettingsPolicyCount is the number of relevant ProxySettingsPolicies
78+ // attached at the Route level.
79+ RouteAttachedProxySettingsPolicyCount int64
7480}
7581
7682// NGFResourceCounts stores the counts of all relevant resources that NGF processes and generates configuration from.
@@ -110,12 +116,6 @@ type NGFResourceCounts struct {
110116 UpstreamSettingsPolicyCount int64
111117 // GatewayAttachedNpCount is the total number of NginxProxy resources that are attached to a Gateway.
112118 GatewayAttachedNpCount int64
113- // GatewayAttachedProxySettingsPolicyCount is the number of relevant ProxySettingsPolicies
114- // attached at the Gateway level.
115- GatewayAttachedProxySettingsPolicyCount int64
116- // RouteAttachedProxySettingsPolicyCount is the number of relevant ProxySettingsPolicies
117- // attached at the Route level.
118- RouteAttachedProxySettingsPolicyCount int64
119119}
120120
121121func (rc * NGFResourceCounts ) CountPolicies (g * graph.Graph ) {
@@ -137,21 +137,32 @@ func (rc *NGFResourceCounts) CountPolicies(g *graph.Graph) {
137137 rc .ObservabilityPolicyCount ++
138138 case kinds .UpstreamSettingsPolicy :
139139 rc .UpstreamSettingsPolicyCount ++
140- case kinds .ProxySettingsPolicy :
140+ }
141+ }
142+ }
143+
144+ func CountProxySettingsPolicies (g * graph.Graph ) (int64 , int64 ) {
145+ gatewayAttachedProxySettingsPolicyCount := int64 (0 )
146+ routeAttachedProxySettingsPolicyCount := int64 (0 )
147+
148+ for policyKey , policy := range g .NGFPolicies {
149+ if policyKey .GVK .Kind == kinds .ProxySettingsPolicy {
141150 if len (policy .TargetRefs ) == 0 {
142151 continue
143152 }
144153
145154 for _ , tr := range policy .TargetRefs {
146155 switch tr .Kind {
147156 case kinds .Gateway :
148- rc . GatewayAttachedProxySettingsPolicyCount ++
157+ gatewayAttachedProxySettingsPolicyCount ++
149158 case kinds .HTTPRoute , kinds .GRPCRoute :
150- rc . RouteAttachedProxySettingsPolicyCount ++
159+ routeAttachedProxySettingsPolicyCount ++
151160 }
152161 }
153162 }
154163 }
164+
165+ return gatewayAttachedProxySettingsPolicyCount , routeAttachedProxySettingsPolicyCount
155166}
156167
157168// DataCollectorConfig holds configuration parameters for DataCollectorImpl.
@@ -228,6 +239,7 @@ func (c DataCollectorImpl) Collect(ctx context.Context) (Data, error) {
228239 buildOs = "alpine"
229240 }
230241 inferencePoolCount := int64 (len (g .ReferencedInferencePools ))
242+ gatewayAttachedProxySettingsPolicyCount , routeAttachedProxySettingsPolicyCount := CountProxySettingsPolicies (g )
231243
232244 data := Data {
233245 Data : tel.Data {
@@ -240,17 +252,19 @@ func (c DataCollectorImpl) Collect(ctx context.Context) (Data, error) {
240252 InstallationID : deploymentID ,
241253 ClusterNodeCount : int64 (clusterInfo .NodeCount ),
242254 },
243- NGFResourceCounts : graphResourceCount ,
244- ImageSource : c .cfg .ImageSource ,
245- BuildOS : buildOs ,
246- FlagNames : c .cfg .Flags .Names ,
247- FlagValues : c .cfg .Flags .Values ,
248- SnippetsFiltersDirectives : snippetsFiltersDirectives ,
249- SnippetsFiltersDirectivesCount : snippetsFiltersDirectivesCount ,
250- NginxPodCount : nginxPodCount ,
251- ControlPlanePodCount : int64 (replicaCount ),
252- NginxOneConnectionEnabled : c .cfg .NginxOneConsoleConnection ,
253- InferencePoolCount : inferencePoolCount ,
255+ NGFResourceCounts : graphResourceCount ,
256+ ImageSource : c .cfg .ImageSource ,
257+ BuildOS : buildOs ,
258+ FlagNames : c .cfg .Flags .Names ,
259+ FlagValues : c .cfg .Flags .Values ,
260+ SnippetsFiltersDirectives : snippetsFiltersDirectives ,
261+ SnippetsFiltersDirectivesCount : snippetsFiltersDirectivesCount ,
262+ NginxPodCount : nginxPodCount ,
263+ ControlPlanePodCount : int64 (replicaCount ),
264+ NginxOneConnectionEnabled : c .cfg .NginxOneConsoleConnection ,
265+ InferencePoolCount : inferencePoolCount ,
266+ GatewayAttachedProxySettingsPolicyCount : gatewayAttachedProxySettingsPolicyCount ,
267+ RouteAttachedProxySettingsPolicyCount : routeAttachedProxySettingsPolicyCount ,
254268 }
255269
256270 return data , nil
0 commit comments