Skip to content

Commit 641d9c6

Browse files
committed
add nginx one console connection telemetry field
1 parent 6c410e5 commit 641d9c6

File tree

7 files changed

+32
-23
lines changed

7 files changed

+32
-23
lines changed

internal/controller/manager.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,9 @@ func StartManager(cfg config.Config) error {
287287
Namespace: cfg.GatewayPodConfig.Namespace,
288288
Name: cfg.GatewayPodConfig.Name,
289289
},
290-
ImageSource: cfg.ImageSource,
291-
Flags: cfg.Flags,
290+
ImageSource: cfg.ImageSource,
291+
Flags: cfg.Flags,
292+
NginxOneConsoleSecretName: cfg.NginxOneConsoleTelemetryConfig.DataplaneKeySecretName,
292293
})
293294

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

internal/controller/telemetry/collector.go

Lines changed: 11 additions & 14 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.
@@ -107,20 +109,14 @@ type NGFResourceCounts struct {
107109

108110
// DataCollectorConfig holds configuration parameters for DataCollectorImpl.
109111
type DataCollectorConfig struct {
110-
// K8sClientReader is a Kubernetes API client Reader.
111-
K8sClientReader client.Reader
112-
// GraphGetter allows us to get the Graph.
113-
GraphGetter GraphGetter
114-
// ConfigurationGetter allows us to get the Configuration.
115-
ConfigurationGetter ConfigurationGetter
116-
// Version is the NGF version.
117-
Version string
118-
// PodNSName is the NamespacedName of the NGF Pod.
119-
PodNSName types.NamespacedName
120-
// ImageSource is the source of the NGF image.
121-
ImageSource string
122-
// Flags contains the command-line NGF flag keys and values.
123-
Flags config.Flags
112+
K8sClientReader client.Reader
113+
GraphGetter GraphGetter
114+
ConfigurationGetter ConfigurationGetter
115+
PodNSName types.NamespacedName
116+
Version string
117+
ImageSource string
118+
NginxOneConsoleSecretName string
119+
Flags config.Flags
124120
}
125121

126122
// DataCollectorImpl is am implementation of DataCollector.
@@ -189,6 +185,7 @@ func (c DataCollectorImpl) Collect(ctx context.Context) (Data, error) {
189185
SnippetsFiltersDirectivesCount: snippetsFiltersDirectivesCount,
190186
NginxPodCount: nginxPodCount,
191187
ControlPlanePodCount: int64(replicaCount),
188+
NginxOneConnectionEnabled: c.cfg.NginxOneConsoleSecretName != "",
192189
}
193190

194191
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+
NginxOneConsoleSecretName: "nginx-one-console-secret",
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)