Skip to content

Add nginx one console telemetry field #3731

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
merged 1 commit into from
Aug 13, 2025
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
5 changes: 3 additions & 2 deletions internal/controller/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,9 @@ func StartManager(cfg config.Config) error {
Namespace: cfg.GatewayPodConfig.Namespace,
Name: cfg.GatewayPodConfig.Name,
},
ImageSource: cfg.ImageSource,
Flags: cfg.Flags,
ImageSource: cfg.ImageSource,
Flags: cfg.Flags,
NginxOneConsoleConnection: cfg.NginxOneConsoleTelemetryConfig.DataplaneKeySecretName != "",
})

job, err := createTelemetryJob(cfg, dataCollector, healthChecker.getReadyCh())
Expand Down
9 changes: 7 additions & 2 deletions internal/controller/telemetry/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type Data struct {
NginxPodCount int64
// ControlPlanePodCount is the total number of NGF control plane Pods.
ControlPlanePodCount int64
// NginxOneConnectionEnabled is a boolean that indicates whether the connection to the Nginx One Console is enabled.
NginxOneConnectionEnabled bool
}

// NGFResourceCounts stores the counts of all relevant resources that NGF processes and generates configuration from.
Expand Down Expand Up @@ -113,14 +115,16 @@ type DataCollectorConfig struct {
GraphGetter GraphGetter
// ConfigurationGetter allows us to get the Configuration.
ConfigurationGetter ConfigurationGetter
// Version is the NGF version.
Version string
// PodNSName is the NamespacedName of the NGF Pod.
PodNSName types.NamespacedName
// Version is the NGF version.
Version string
// ImageSource is the source of the NGF image.
ImageSource string
// Flags contains the command-line NGF flag keys and values.
Flags config.Flags
// NginxOneConsoleConnection is a boolean that indicates whether the connection to the Nginx One Console is enabled.
NginxOneConsoleConnection bool
}

// DataCollectorImpl is am implementation of DataCollector.
Expand Down Expand Up @@ -189,6 +193,7 @@ func (c DataCollectorImpl) Collect(ctx context.Context) (Data, error) {
SnippetsFiltersDirectivesCount: snippetsFiltersDirectivesCount,
NginxPodCount: nginxPodCount,
ControlPlanePodCount: int64(replicaCount),
NginxOneConnectionEnabled: c.cfg.NginxOneConsoleConnection,
}

return data, nil
Expand Down
17 changes: 10 additions & 7 deletions internal/controller/telemetry/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ var _ = Describe("Collector", Ordered, func() {
FlagValues: flags.Values,
SnippetsFiltersDirectives: []string{},
SnippetsFiltersDirectivesCount: []int64{},
NginxOneConnectionEnabled: true,
}

k8sClientReader = &kubernetesfakes.FakeReader{}
Expand All @@ -186,13 +187,14 @@ var _ = Describe("Collector", Ordered, func() {
fakeConfigurationGetter.GetLatestConfigurationReturns(nil)

dataCollector = telemetry.NewDataCollectorImpl(telemetry.DataCollectorConfig{
K8sClientReader: k8sClientReader,
GraphGetter: fakeGraphGetter,
ConfigurationGetter: fakeConfigurationGetter,
Version: version,
PodNSName: podNSName,
ImageSource: "local",
Flags: flags,
K8sClientReader: k8sClientReader,
GraphGetter: fakeGraphGetter,
ConfigurationGetter: fakeConfigurationGetter,
Version: version,
PodNSName: podNSName,
ImageSource: "local",
Flags: flags,
NginxOneConsoleConnection: true,
})

baseGetCalls = createGetCallsFunc(ngfPod, ngfReplicaSet, kubeNamespace)
Expand Down Expand Up @@ -516,6 +518,7 @@ var _ = Describe("Collector", Ordered, func() {
// empty + one gateway using daemonset
expData.NginxPodCount = int64(8)
expData.ControlPlanePodCount = int64(2)
expData.NginxOneConnectionEnabled = true

data, err := dataCollector.Collect(ctx)
Expect(err).ToNot(HaveOccurred())
Expand Down
3 changes: 3 additions & 0 deletions internal/controller/telemetry/data.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,8 @@ attached at the Gateway level. */
/** ControlPlanePodCount is the total number of NGF control plane Pods. */
long? ControlPlanePodCount = null;

/** NginxOneConnectionEnabled is a boolean that indicates whether the connection to the Nginx One Console is enabled. */
boolean? NginxOneConnectionEnabled = null;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (d *Data) Attributes() []attribute.KeyValue {
attrs = append(attrs, d.NGFResourceCounts.Attributes()...)
attrs = append(attrs, attribute.Int64("NginxPodCount", d.NginxPodCount))
attrs = append(attrs, attribute.Int64("ControlPlanePodCount", d.ControlPlanePodCount))
attrs = append(attrs, attribute.Bool("NginxOneConnectionEnabled", d.NginxOneConnectionEnabled))

return attrs
}
Expand Down
3 changes: 3 additions & 0 deletions internal/controller/telemetry/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func TestDataAttributes(t *testing.T) {
SnippetsFiltersDirectivesCount: []int64{3, 2, 1},
NginxPodCount: 3,
ControlPlanePodCount: 3,
NginxOneConnectionEnabled: true,
}

expected := []attribute.KeyValue{
Expand Down Expand Up @@ -84,6 +85,7 @@ func TestDataAttributes(t *testing.T) {
attribute.Int64("GatewayAttachedNpCount", 15),
attribute.Int64("NginxPodCount", 3),
attribute.Int64("ControlPlanePodCount", 3),
attribute.Bool("NginxOneConnectionEnabled", true),
}

result := data.Attributes()
Expand Down Expand Up @@ -129,6 +131,7 @@ func TestDataAttributesWithEmptyData(t *testing.T) {
attribute.Int64("GatewayAttachedNpCount", 0),
attribute.Int64("NginxPodCount", 0),
attribute.Int64("ControlPlanePodCount", 0),
attribute.Bool("NginxOneConnectionEnabled", false),
}

result := data.Attributes()
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 @@ -95,6 +95,7 @@ var _ = Describe("Telemetry test with OTel collector", Label("telemetry"), func(
"GatewayAttachedNpCount: Int(0)",
"NginxPodCount: Int(0)",
"ControlPlanePodCount: Int(1)",
"NginxOneConnectionEnabled: Bool(false)",
},
)
})
Expand Down