Skip to content

Commit f8bbfdd

Browse files
authored
Cherry pick: Add nginx one console telemetry field (#3731)
Add nginx one console connection telemetry field (#3717) Problem: We want to know how many clusters are connected to NGINX One console. Solution: Reports product telemetry to report if cluster is connected to NGINX One console
1 parent b6f8fcf commit f8bbfdd

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
lines changed

internal/controller/manager.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,9 @@ func StartManager(cfg config.Config) error {
289289
Namespace: cfg.GatewayPodConfig.Namespace,
290290
Name: cfg.GatewayPodConfig.Name,
291291
},
292-
ImageSource: cfg.ImageSource,
293-
Flags: cfg.Flags,
292+
ImageSource: cfg.ImageSource,
293+
Flags: cfg.Flags,
294+
NginxOneConsoleConnection: cfg.NginxOneConsoleTelemetryConfig.DataplaneKeySecretName != "",
294295
})
295296

296297
job, err := createTelemetryJob(cfg, dataCollector, healthChecker.getReadyCh())

internal/controller/telemetry/collector.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ type Data struct {
6464
NginxPodCount int64
6565
// ControlPlanePodCount is the total number of NGF control plane Pods.
6666
ControlPlanePodCount int64
67+
// NginxOneConnectionEnabled is a boolean that indicates whether the connection to the Nginx One Console is enabled.
68+
NginxOneConnectionEnabled bool
6769
}
6870

6971
// NGFResourceCounts stores the counts of all relevant resources that NGF processes and generates configuration from.
@@ -113,14 +115,16 @@ type DataCollectorConfig struct {
113115
GraphGetter GraphGetter
114116
// ConfigurationGetter allows us to get the Configuration.
115117
ConfigurationGetter ConfigurationGetter
116-
// Version is the NGF version.
117-
Version string
118118
// PodNSName is the NamespacedName of the NGF Pod.
119119
PodNSName types.NamespacedName
120+
// Version is the NGF version.
121+
Version string
120122
// ImageSource is the source of the NGF image.
121123
ImageSource string
122124
// Flags contains the command-line NGF flag keys and values.
123125
Flags config.Flags
126+
// NginxOneConsoleConnection is a boolean that indicates whether the connection to the Nginx One Console is enabled.
127+
NginxOneConsoleConnection bool
124128
}
125129

126130
// DataCollectorImpl is am implementation of DataCollector.
@@ -189,6 +193,7 @@ func (c DataCollectorImpl) Collect(ctx context.Context) (Data, error) {
189193
SnippetsFiltersDirectivesCount: snippetsFiltersDirectivesCount,
190194
NginxPodCount: nginxPodCount,
191195
ControlPlanePodCount: int64(replicaCount),
196+
NginxOneConnectionEnabled: c.cfg.NginxOneConsoleConnection,
192197
}
193198

194199
return data, nil

internal/controller/telemetry/collector_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ var _ = Describe("Collector", Ordered, func() {
176176
FlagValues: flags.Values,
177177
SnippetsFiltersDirectives: []string{},
178178
SnippetsFiltersDirectivesCount: []int64{},
179+
NginxOneConnectionEnabled: true,
179180
}
180181

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

188189
dataCollector = telemetry.NewDataCollectorImpl(telemetry.DataCollectorConfig{
189-
K8sClientReader: k8sClientReader,
190-
GraphGetter: fakeGraphGetter,
191-
ConfigurationGetter: fakeConfigurationGetter,
192-
Version: version,
193-
PodNSName: podNSName,
194-
ImageSource: "local",
195-
Flags: flags,
190+
K8sClientReader: k8sClientReader,
191+
GraphGetter: fakeGraphGetter,
192+
ConfigurationGetter: fakeConfigurationGetter,
193+
Version: version,
194+
PodNSName: podNSName,
195+
ImageSource: "local",
196+
Flags: flags,
197+
NginxOneConsoleConnection: true,
196198
})
197199

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

520523
data, err := dataCollector.Collect(ctx)
521524
Expect(err).ToNot(HaveOccurred())

internal/controller/telemetry/data.avdl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,8 @@ attached at the Gateway level. */
111111
/** ControlPlanePodCount is the total number of NGF control plane Pods. */
112112
long? ControlPlanePodCount = null;
113113

114+
/** NginxOneConnectionEnabled is a boolean that indicates whether the connection to the Nginx One Console is enabled. */
115+
boolean? NginxOneConnectionEnabled = null;
116+
114117
}
115118
}

internal/controller/telemetry/data_attributes_generated.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func (d *Data) Attributes() []attribute.KeyValue {
2222
attrs = append(attrs, d.NGFResourceCounts.Attributes()...)
2323
attrs = append(attrs, attribute.Int64("NginxPodCount", d.NginxPodCount))
2424
attrs = append(attrs, attribute.Int64("ControlPlanePodCount", d.ControlPlanePodCount))
25+
attrs = append(attrs, attribute.Bool("NginxOneConnectionEnabled", d.NginxOneConnectionEnabled))
2526

2627
return attrs
2728
}

internal/controller/telemetry/data_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func TestDataAttributes(t *testing.T) {
4646
SnippetsFiltersDirectivesCount: []int64{3, 2, 1},
4747
NginxPodCount: 3,
4848
ControlPlanePodCount: 3,
49+
NginxOneConnectionEnabled: true,
4950
}
5051

5152
expected := []attribute.KeyValue{
@@ -84,6 +85,7 @@ func TestDataAttributes(t *testing.T) {
8485
attribute.Int64("GatewayAttachedNpCount", 15),
8586
attribute.Int64("NginxPodCount", 3),
8687
attribute.Int64("ControlPlanePodCount", 3),
88+
attribute.Bool("NginxOneConnectionEnabled", true),
8789
}
8890

8991
result := data.Attributes()
@@ -129,6 +131,7 @@ func TestDataAttributesWithEmptyData(t *testing.T) {
129131
attribute.Int64("GatewayAttachedNpCount", 0),
130132
attribute.Int64("NginxPodCount", 0),
131133
attribute.Int64("ControlPlanePodCount", 0),
134+
attribute.Bool("NginxOneConnectionEnabled", false),
132135
}
133136

134137
result := data.Attributes()

tests/suite/telemetry_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ var _ = Describe("Telemetry test with OTel collector", Label("telemetry"), func(
9595
"GatewayAttachedNpCount: Int(0)",
9696
"NginxPodCount: Int(0)",
9797
"ControlPlanePodCount: Int(1)",
98+
"NginxOneConnectionEnabled: Bool(false)",
9899
},
99100
)
100101
})

0 commit comments

Comments
 (0)