Skip to content
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

Add Installation Flags to Telemetry #5586

Merged
merged 15 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions docs/content/overview/product-telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ These are the data points collected and reported by NGINX Ingress Controller:
- **GlobalConfiguration** Represents the use of a GlobalConfiguration resource.
- **AppProtectVersion** The AppProtect version
- **IsPlus** Represents whether NGINX is Plus or OSS
- **InstallationFlags* List of flags managed by NGINX Ingress Controller
AlexFenlon marked this conversation as resolved.
Show resolved Hide resolved

## Opt out

Expand Down
14 changes: 14 additions & 0 deletions internal/telemetry/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"os"
"strings"

metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -202,6 +203,19 @@ func (c *Collector) IsPlusEnabled() bool {
return c.Config.IsPlus
}

// InstallationFlags returns the list of all flags
func (c *Collector) InstallationFlags() []string {
flags := os.Args[1:]
// tests that compare the report currently break with this addition,
AlexFenlon marked this conversation as resolved.
Show resolved Hide resolved
// this is temp fix until tests are refactored
for _, flag := range flags {
if flag == "-test.paniconexit0" {
AlexFenlon marked this conversation as resolved.
Show resolved Hide resolved
return []string{}
}
}
return flags
}

// lookupPlatform takes a string representing a K8s PlatformID
// retrieved from a cluster node and returns a string
// representing the platform name.
Expand Down
5 changes: 5 additions & 0 deletions internal/telemetry/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (c *Collector) Collect(ctx context.Context) {
IngressAnnotations: report.IngressAnnotations,
AppProtectVersion: report.AppProtectVersion,
IsPlus: report.IsPlus,
InstallationFlags: report.InstallationFlags,
},
}

Expand Down Expand Up @@ -183,6 +184,7 @@ type Report struct {
IngressAnnotations []string
AppProtectVersion string
IsPlus bool
InstallationFlags []string
}

// BuildReport takes context, collects telemetry data and builds the report.
Expand Down Expand Up @@ -255,6 +257,8 @@ func (c *Collector) BuildReport(ctx context.Context) (Report, error) {

isPlus := c.IsPlusEnabled()

installationFlags := c.InstallationFlags()

return Report{
Name: "NIC",
Version: c.Config.Version,
Expand Down Expand Up @@ -284,5 +288,6 @@ func (c *Collector) BuildReport(ctx context.Context) (Report, error) {
IngressAnnotations: ingressAnnotations,
AppProtectVersion: appProtectVersion,
IsPlus: isPlus,
InstallationFlags: installationFlags,
}, err
}
3 changes: 3 additions & 0 deletions internal/telemetry/data.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,8 @@ It is the UID of the `kube-system` Namespace. */
/** IsPlus represents whether NGINX is Plus or OSS */
boolean? IsPlus = null;

/** InstallationFlags is the list of flags resources managed by NGINX Ingress Controller */
union {null, array<string>} InstallationFlags = null;

}
}
2 changes: 2 additions & 0 deletions internal/telemetry/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,6 @@ type NICResourceCounts struct {
AppProtectVersion string
// IsPlus represents whether NGINX is Plus or OSS
IsPlus bool
// InstallationFlags is the list of flags resources managed by NGINX Ingress Controller
InstallationFlags []string
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (d *NICResourceCounts) Attributes() []attribute.KeyValue {
attrs = append(attrs, attribute.StringSlice("IngressAnnotations", d.IngressAnnotations))
attrs = append(attrs, attribute.String("AppProtectVersion", d.AppProtectVersion))
attrs = append(attrs, attribute.Bool("IsPlus", d.IsPlus))
attrs = append(attrs, attribute.StringSlice("InstallationFlags", d.InstallationFlags))

return attrs
}
Expand Down
Loading