Skip to content

Commit

Permalink
Add collection of SnippetsFilter count
Browse files Browse the repository at this point in the history
  • Loading branch information
bjee19 committed Oct 10, 2024
1 parent b2f0bfe commit ee3a4fd
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions internal/mode/static/telemetry/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ type NGFResourceCounts struct {
ObservabilityPolicyCount int64
// NginxProxyCount is the number of NginxProxies.
NginxProxyCount int64
// SnippetsFilterCount is the number of SnippetsFilters.
SnippetsFilterCount int64
}

// DataCollectorConfig holds configuration parameters for DataCollectorImpl.
Expand Down Expand Up @@ -227,6 +229,8 @@ func collectGraphResourceCount(
ngfResourceCounts.NginxProxyCount = 1
}

ngfResourceCounts.SnippetsFilterCount = int64(len(g.SnippetsFilters))

return ngfResourceCounts, nil
}

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

config := &dataplane.Configuration{
Expand Down Expand Up @@ -379,6 +384,7 @@ var _ = Describe("Collector", Ordered, func() {
RouteAttachedClientSettingsPolicyCount: 2,
ObservabilityPolicyCount: 1,
NginxProxyCount: 1,
SnippetsFilterCount: 3,
}
expData.ClusterVersion = "1.29.2"
expData.ClusterPlatform = "kind"
Expand Down Expand Up @@ -549,6 +555,9 @@ var _ = Describe("Collector", Ordered, func() {
}: {},
},
NginxProxy: &graph.NginxProxy{},
SnippetsFilters: map[types.NamespacedName]*graph.SnippetsFilter{
{Namespace: "test", Name: "sf-1"}: {},
},
}

config1 = &dataplane.Configuration{
Expand Down Expand Up @@ -622,6 +631,7 @@ var _ = Describe("Collector", Ordered, func() {
RouteAttachedClientSettingsPolicyCount: 1,
ObservabilityPolicyCount: 1,
NginxProxyCount: 1,
SnippetsFilterCount: 1,
}

data, err := dataCollector.Collect(ctx)
Expand All @@ -647,6 +657,7 @@ var _ = Describe("Collector", Ordered, func() {
RouteAttachedClientSettingsPolicyCount: 0,
ObservabilityPolicyCount: 0,
NginxProxyCount: 0,
SnippetsFilterCount: 0,
}

data, err := dataCollector.Collect(ctx)
Expand Down
3 changes: 3 additions & 0 deletions internal/mode/static/telemetry/data.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ attached at the Gateway level. */
/** NginxProxyCount is the number of NginxProxies. */
long? NginxProxyCount = null;

/** SnippetsFilterCount is the number of SnippetsFilters. */
long? SnippetsFilterCount = null;

/** NGFReplicaCount is the number of replicas of the NGF Pod. */
long? NGFReplicaCount = null;

Expand Down
3 changes: 3 additions & 0 deletions internal/mode/static/telemetry/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func TestDataAttributes(t *testing.T) {
RouteAttachedClientSettingsPolicyCount: 10,
ObservabilityPolicyCount: 11,
NginxProxyCount: 12,
SnippetsFilterCount: 13,
},
NGFReplicaCount: 3,
}
Expand Down Expand Up @@ -68,6 +69,7 @@ func TestDataAttributes(t *testing.T) {
attribute.Int64("RouteAttachedClientSettingsPolicyCount", 10),
attribute.Int64("ObservabilityPolicyCount", 11),
attribute.Int64("NginxProxyCount", 12),
attribute.Int64("SnippetsFilterCount", 13),
attribute.Int64("NGFReplicaCount", 3),
}

Expand Down Expand Up @@ -107,6 +109,7 @@ func TestDataAttributesWithEmptyData(t *testing.T) {
attribute.Int64("RouteAttachedClientSettingsPolicyCount", 0),
attribute.Int64("ObservabilityPolicyCount", 0),
attribute.Int64("NginxProxyCount", 0),
attribute.Int64("SnippetsFilterCount", 0),
attribute.Int64("NGFReplicaCount", 0),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func (d *NGFResourceCounts) Attributes() []attribute.KeyValue {
attrs = append(attrs, attribute.Int64("RouteAttachedClientSettingsPolicyCount", d.RouteAttachedClientSettingsPolicyCount))
attrs = append(attrs, attribute.Int64("ObservabilityPolicyCount", d.ObservabilityPolicyCount))
attrs = append(attrs, attribute.Int64("NginxProxyCount", d.NginxProxyCount))
attrs = append(attrs, attribute.Int64("SnippetsFilterCount", d.SnippetsFilterCount))

return attrs
}
Expand Down
2 changes: 1 addition & 1 deletion site/content/overview/product-telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`, `TLSRoutes`, `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`, `SnippetsFilters`, and `Endpoints`. The data within these resources is **not** collected.

This data is used to identify the following information:

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 @@ -85,6 +85,7 @@ var _ = Describe("Telemetry test with OTel collector", Label("telemetry"), func(
"RouteAttachedClientSettingsPolicyCount: Int(0)",
"ObservabilityPolicyCount: Int(0)",
"NginxProxyCount: Int(0)",
"SnippetsFilterCount: Int(0)",
"NGFReplicaCount: Int(1)",
},
)
Expand Down

0 comments on commit ee3a4fd

Please sign in to comment.