Skip to content

Collect UpstreamSettingsPolicyCount in telemetry #2922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
4 changes: 4 additions & 0 deletions internal/mode/static/telemetry/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ type NGFResourceCounts struct {
NginxProxyCount int64
// SnippetsFilterCount is the number of SnippetsFilters.
SnippetsFilterCount int64
// UpstreamSettingsPolicyCount is the number of UpstreamSettingsPolicies.
UpstreamSettingsPolicyCount int64
}

// DataCollectorConfig holds configuration parameters for DataCollectorImpl.
Expand Down Expand Up @@ -239,6 +241,8 @@ func collectGraphResourceCount(
}
case kinds.ObservabilityPolicy:
ngfResourceCounts.ObservabilityPolicyCount++
case kinds.UpstreamSettingsPolicy:
ngfResourceCounts.UpstreamSettingsPolicyCount++
}
}

Expand Down
27 changes: 11 additions & 16 deletions internal/mode/static/telemetry/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ var _ = Describe("Collector", Ordered, func() {
NsName: types.NamespacedName{Namespace: "test", Name: "ObservabilityPolicy-1"},
GVK: schema.GroupVersionKind{Kind: kinds.ObservabilityPolicy},
}: {},
{
NsName: types.NamespacedName{Namespace: "test", Name: "UpstreamSettingsPolicy-1"},
GVK: schema.GroupVersionKind{Kind: kinds.UpstreamSettingsPolicy},
}: {},
},
NginxProxy: &graph.NginxProxy{},
SnippetsFilters: map[types.NamespacedName]*graph.SnippetsFilter{
Expand Down Expand Up @@ -412,6 +416,7 @@ var _ = Describe("Collector", Ordered, func() {
ObservabilityPolicyCount: 1,
NginxProxyCount: 1,
SnippetsFilterCount: 3,
UpstreamSettingsPolicyCount: 1,
}
expData.ClusterVersion = "1.29.2"
expData.ClusterPlatform = "kind"
Expand Down Expand Up @@ -603,6 +608,10 @@ var _ = Describe("Collector", Ordered, func() {
NsName: types.NamespacedName{Namespace: "test", Name: "ObservabilityPolicy-1"},
GVK: schema.GroupVersionKind{Kind: kinds.ObservabilityPolicy},
}: {},
{
NsName: types.NamespacedName{Namespace: "test", Name: "UpstreamSettingsPolicy-1"},
GVK: schema.GroupVersionKind{Kind: kinds.UpstreamSettingsPolicy},
}: {},
},
NginxProxy: &graph.NginxProxy{},
SnippetsFilters: map[types.NamespacedName]*graph.SnippetsFilter{
Expand Down Expand Up @@ -682,6 +691,7 @@ var _ = Describe("Collector", Ordered, func() {
ObservabilityPolicyCount: 1,
NginxProxyCount: 1,
SnippetsFilterCount: 1,
UpstreamSettingsPolicyCount: 1,
}

data, err := dataCollector.Collect(ctx)
Expand All @@ -693,22 +703,7 @@ var _ = Describe("Collector", Ordered, func() {
It("ignores invalid and empty upstreams", func(ctx SpecContext) {
fakeGraphGetter.GetLatestGraphReturns(&graph.Graph{})
fakeConfigurationGetter.GetLatestConfigurationReturns(invalidUpstreamsConfig)
expData.NGFResourceCounts = telemetry.NGFResourceCounts{
GatewayCount: 0,
GatewayClassCount: 0,
HTTPRouteCount: 0,
TLSRouteCount: 0,
SecretCount: 0,
ServiceCount: 0,
EndpointCount: 0,
GRPCRouteCount: 0,
BackendTLSPolicyCount: 0,
GatewayAttachedClientSettingsPolicyCount: 0,
RouteAttachedClientSettingsPolicyCount: 0,
ObservabilityPolicyCount: 0,
NginxProxyCount: 0,
SnippetsFilterCount: 0,
}
expData.NGFResourceCounts = telemetry.NGFResourceCounts{}

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 @@ -99,6 +99,9 @@ attached at the Gateway level. */
/** SnippetsFilterCount is the number of SnippetsFilters. */
long? SnippetsFilterCount = null;

/** UpstreamSettingsPolicyCount is the number of UpstreamSettingsPolicies. */
long? UpstreamSettingsPolicyCount = 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 @@ -39,6 +39,7 @@ func TestDataAttributes(t *testing.T) {
ObservabilityPolicyCount: 11,
NginxProxyCount: 12,
SnippetsFilterCount: 13,
UpstreamSettingsPolicyCount: 14,
},
NGFReplicaCount: 3,
SnippetsFiltersDirectives: []string{"main-three-count", "http-two-count", "server-one-count"},
Expand Down Expand Up @@ -77,6 +78,7 @@ func TestDataAttributes(t *testing.T) {
attribute.Int64("ObservabilityPolicyCount", 11),
attribute.Int64("NginxProxyCount", 12),
attribute.Int64("SnippetsFilterCount", 13),
attribute.Int64("UpstreamSettingsPolicyCount", 14),
attribute.Int64("NGFReplicaCount", 3),
}

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

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

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`, `SnippetsFilters`, 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`, `UpstreamSettingsPolicies`, `SnippetsFilters`, and `Endpoints`. The data within these resources is **not** collected.
- **SnippetsFilters Info**a list of directive-context strings from applied SnippetFilters and a total count per strings. The actual value of any NGINX directive 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 @@ -88,6 +88,7 @@ var _ = Describe("Telemetry test with OTel collector", Label("telemetry"), func(
"ObservabilityPolicyCount: Int(0)",
"NginxProxyCount: Int(0)",
"SnippetsFilterCount: Int(0)",
"UpstreamSettingsPolicyCount: Int(0)",
"NGFReplicaCount: Int(1)",
},
)
Expand Down
Loading