Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4103612
Add BuilOS to telemetry
shaun-nx Oct 7, 2025
06c853d
Run `make generate` to update data.avdl and generated attributes
shaun-nx Oct 7, 2025
aeb9042
Merge branch 'main' into feat/buildos-telemetry
shaun-nx Oct 8, 2025
4bc9935
Update module google.golang.org/grpc to v1.76.0 (#4029)
renovate[bot] Oct 8, 2025
014b64b
Update module github.com/prometheus/common to v0.67.1 (#4042)
renovate[bot] Oct 8, 2025
1d9dd4a
Update github/codeql-action action to v4 (#4043)
renovate[bot] Oct 8, 2025
3d58eb3
Update nginx Docker tag to v1.29.2 (#4041)
renovate[bot] Oct 8, 2025
db96078
Update ghcr.io/nginx/dependencies/nginx-ubi:ubi9 Docker digest to 46e…
renovate[bot] Oct 9, 2025
b7d7dd9
Pass os.Getenv("BUILD_OS") directly to manager
shaun-nx Oct 9, 2025
5e5a3c5
Fix failing unit tests
shaun-nx Oct 9, 2025
a3d5a8e
Revert data struct and add nolint
shaun-nx Oct 9, 2025
2d34749
Merge branch 'main' into feat/buildos-telemetry
shaun-nx Oct 9, 2025
00b418d
Fix //nolint lint error
shaun-nx Oct 9, 2025
8022051
Add comment about //nolint
shaun-nx Oct 9, 2025
c9b7a7d
Merge branch 'main' into feat/buildos-telemetry
shaun-nx Oct 10, 2025
e0110cb
Merge branch 'main' into feat/buildos-telemetry
shaun-nx Oct 10, 2025
75f6de7
Add buildOs to normal test case
shaun-nx Oct 10, 2025
f56e9f2
Update buildOS comment and run `make generate`
shaun-nx Oct 10, 2025
3f0b3f3
Merge branch 'main' into feat/buildos-telemetry
shaun-nx Oct 10, 2025
4153485
Merge branch 'main' into feat/buildos-telemetry
shaun-nx Oct 13, 2025
f87a2ce
Merge branch 'main' into feat/buildos-telemetry
shaun-nx Oct 13, 2025
f8cfab6
Add `ENv BUILD_OS` to Dockerfiles
shaun-nx Oct 13, 2025
9688ca7
Merge branch 'main' into feat/buildos-telemetry
shaun-nx Oct 15, 2025
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
6 changes: 6 additions & 0 deletions cmd/gateway/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ func createControllerCommand() *cobra.Command {
imageSource = "unknown"
}

buildOs := os.Getenv("BUILD_OS")
if buildOs == "" {
buildOs = "alpine"
}

period, err := time.ParseDuration(telemetryReportPeriod)
if err != nil {
return fmt.Errorf("error parsing telemetry report period: %w", err)
Expand Down Expand Up @@ -271,6 +276,7 @@ func createControllerCommand() *cobra.Command {
Plus: plus,
ExperimentalFeatures: gwExperimentalFeatures,
ImageSource: imageSource,
BuildOS: buildOs,
Flags: config.Flags{
Names: flagKeys,
Values: flagValues,
Expand Down
2 changes: 2 additions & 0 deletions internal/controller/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type Config struct {
GatewayClassName string
// ImageSource is the source of the NGINX Gateway image.
ImageSource string
// BuildOS is the OS the NGF and NGINX binary was built on.
BuildOS string
// GatewayCtlrName is the name of this controller.
GatewayCtlrName string
// UsageReportConfig specifies the NGINX Plus usage reporting configuration.
Expand Down
1 change: 1 addition & 0 deletions internal/controller/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ func StartManager(cfg config.Config) error {
Name: cfg.GatewayPodConfig.Name,
},
ImageSource: cfg.ImageSource,
BuildOS: cfg.BuildOS,
Flags: cfg.Flags,
NginxOneConsoleConnection: cfg.NginxOneConsoleTelemetryConfig.DataplaneKeySecretName != "",
})
Expand Down
10 changes: 10 additions & 0 deletions internal/controller/telemetry/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Check failure on line 43 in internal/controller/telemetry/collector.go

View workflow job for this annotation

GitHub Actions / Go Lint (.)

fieldalignment: struct with 392 pointer bytes could be 232 (govet)
// 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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -174,6 +178,11 @@

nginxPodCount := getNginxPodCount(g, clusterInfo.NodeCount)

buildOS := c.cfg.BuildOS
if buildOS == "" {
buildOS = "alpine"
}

data := Data{
Data: tel.Data{
ProjectName: "NGF",
Expand All @@ -187,6 +196,7 @@
},
NGFResourceCounts: graphResourceCount,
ImageSource: c.cfg.ImageSource,
BuildOS: buildOS,
FlagNames: c.cfg.Flags.Names,
FlagValues: c.cfg.Flags.Values,
SnippetsFiltersDirectives: snippetsFiltersDirectives,
Expand Down
59 changes: 59 additions & 0 deletions internal/controller/telemetry/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,64 @@
}

var _ = Describe("Collector", Ordered, func() {

Check failure on line 75 in internal/controller/telemetry/collector_test.go

View workflow job for this annotation

GitHub Actions / Go Lint (.)

File is not properly formatted (gofumpt)
Describe("BuildOS field", func() {
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
Expand Down Expand Up @@ -195,6 +253,7 @@
ImageSource: "local",
Flags: flags,
NginxOneConsoleConnection: true,
BuildOS: "",
})

baseGetCalls = createGetCallsFunc(ngfPod, ngfReplicaSet, kubeNamespace)
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 @@ -114,5 +114,8 @@ attached at the Gateway level. */
/** NginxOneConnectionEnabled is a boolean that indicates whether the connection to the Nginx One Console is enabled. */
boolean? NginxOneConnectionEnabled = null;

/** BuildOS is the OS the NGF and NGINX binary was built on. */
string? BuildOS = null;

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

return attrs
}
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 @@ -96,6 +96,7 @@ var _ = Describe("Telemetry test with OTel collector", Label("telemetry"), func(
"NginxPodCount: Int(0)",
"ControlPlanePodCount: Int(1)",
"NginxOneConnectionEnabled: Bool(false)",
"BuildOS:",
},
)
})
Expand Down
Loading