-
Notifications
You must be signed in to change notification settings - Fork 137
OpenShift Support: Product Telemetry #4038
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ | |
// Data is telemetry data. | ||
// | ||
//go:generate go run -tags generator github.com/nginx/telemetry-exporter/cmd/generator -type=Data -scheme -scheme-protocol=NGFProductTelemetry -scheme-df-datatype=ngf-product-telemetry | ||
type Data struct { | ||
// ImageSource tells whether the image was built by GitHub or locally (values are 'gha', 'local', or 'unknown') | ||
ImageSource string | ||
tel.Data // embedding is required by the generator. | ||
|
@@ -66,6 +66,8 @@ | |
ControlPlanePodCount int64 | ||
// NginxOneConnectionEnabled is a boolean that indicates whether the connection to the Nginx One Console is enabled. | ||
NginxOneConnectionEnabled bool | ||
// BuildOS is the OS the NGF and NGINX binary was built on. | ||
BuildOS string | ||
} | ||
|
||
// NGFResourceCounts stores the counts of all relevant resources that NGF processes and generates configuration from. | ||
|
@@ -121,6 +123,8 @@ | |
Version string | ||
// ImageSource is the source of the NGF image. | ||
ImageSource string | ||
// BuildOS is the OS the NGF and NGINX binary was built on. | ||
BuildOS 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. | ||
|
@@ -174,6 +178,11 @@ | |
|
||
nginxPodCount := getNginxPodCount(g, clusterInfo.NodeCount) | ||
|
||
buildOS := c.cfg.BuildOS | ||
if buildOS == "" { | ||
buildOS = "alpine" | ||
} | ||
Comment on lines
+182
to
+184
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need this since we have the check in |
||
|
||
data := Data{ | ||
Data: tel.Data{ | ||
ProjectName: "NGF", | ||
|
@@ -187,6 +196,7 @@ | |
}, | ||
NGFResourceCounts: graphResourceCount, | ||
ImageSource: c.cfg.ImageSource, | ||
BuildOS: buildOS, | ||
FlagNames: c.cfg.Flags.Names, | ||
FlagValues: c.cfg.Flags.Values, | ||
SnippetsFiltersDirectives: snippetsFiltersDirectives, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll need to add the field to the "Normal Case" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,64 @@ | |
} | ||
|
||
var _ = Describe("Collector", Ordered, func() { | ||
|
||
Describe("BuildOS field", func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really think a new Describe block is needed once you add the field in the normal case. Similar to how we don't have a separate Describe block for |
||
var ( | ||
k8sClientReader *kubernetesfakes.FakeReader | ||
fakeGraphGetter *telemetryfakes.FakeGraphGetter | ||
fakeConfigurationGetter *telemetryfakes.FakeConfigurationGetter | ||
version string | ||
podNSName types.NamespacedName | ||
flags config.Flags | ||
) | ||
|
||
BeforeEach(func() { | ||
version = "1.1" | ||
k8sClientReader = &kubernetesfakes.FakeReader{} | ||
fakeGraphGetter = &telemetryfakes.FakeGraphGetter{} | ||
fakeConfigurationGetter = &telemetryfakes.FakeConfigurationGetter{} | ||
podNSName = types.NamespacedName{Namespace: "nginx-gateway", Name: "ngf-pod"} | ||
flags = config.Flags{} | ||
fakeGraphGetter.GetLatestGraphReturns(&graph.Graph{}) | ||
fakeConfigurationGetter.GetLatestConfigurationReturns(nil) | ||
}) | ||
|
||
It("sets BuildOS to 'alpine' when config.BuildOS is empty", func(ctx SpecContext) { | ||
dataCollector := telemetry.NewDataCollectorImpl(telemetry.DataCollectorConfig{ | ||
K8sClientReader: k8sClientReader, | ||
GraphGetter: fakeGraphGetter, | ||
ConfigurationGetter: fakeConfigurationGetter, | ||
Version: version, | ||
PodNSName: podNSName, | ||
ImageSource: "local", | ||
Flags: flags, | ||
NginxOneConsoleConnection: true, | ||
BuildOS: "", | ||
}) | ||
|
||
data, err := dataCollector.Collect(ctx) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(data.BuildOS).To(Equal("alpine")) | ||
}) | ||
|
||
It("sets BuildOS to 'ubi' when config.BuildOS is 'ubi'", func(ctx SpecContext) { | ||
dataCollector := telemetry.NewDataCollectorImpl(telemetry.DataCollectorConfig{ | ||
K8sClientReader: k8sClientReader, | ||
GraphGetter: fakeGraphGetter, | ||
ConfigurationGetter: fakeConfigurationGetter, | ||
Version: version, | ||
PodNSName: podNSName, | ||
ImageSource: "local", | ||
Flags: flags, | ||
NginxOneConsoleConnection: true, | ||
BuildOS: "ubi", | ||
}) | ||
|
||
data, err := dataCollector.Collect(ctx) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(data.BuildOS).To(Equal("ubi")) | ||
}) | ||
}) | ||
var ( | ||
k8sClientReader *kubernetesfakes.FakeReader | ||
fakeGraphGetter *telemetryfakes.FakeGraphGetter | ||
|
@@ -195,6 +253,7 @@ | |
ImageSource: "local", | ||
Flags: flags, | ||
NginxOneConsoleConnection: true, | ||
BuildOS: "", | ||
}) | ||
|
||
baseGetCalls = createGetCallsFunc(ngfPod, ngfReplicaSet, kubeNamespace) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you just call this directly in the collector, rather than calling here and passing the var all the way through the code?