Skip to content

Commit

Permalink
feat(telemetry) add Kong router flavor (#4762)
Browse files Browse the repository at this point in the history
  • Loading branch information
rainest committed Oct 3, 2023
1 parent be62bf7 commit ebb2c52
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ Adding a new version? You'll need three changes:
- Get rid of deprecation warning in logs for unsupported label `global: true` for `KongPlugin`,
it'll be treated as any other label without a special meaning.
[#4737](https://github.com/Kong/kubernetes-ingress-controller/pull/4737)
- Telemetry now reports the router flavor.
[#4762](https://github.com/Kong/kubernetes-ingress-controller/pull/4762)

[KIC Annotations reference]: https://docs.konghq.com/kubernetes-ingress-controller/latest/references/annotations/

Expand Down
6 changes: 6 additions & 0 deletions internal/manager/telemetry/reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,17 @@ func SetupAnonymousReports(
if !ok {
return nil, fmt.Errorf("malformed database configuration found in Kong client root")
}
routerFlavor, ok := cfg["router_flavor"].(string)
if !ok {
// version to old to use router flavor, de facto traditional
routerFlavor = "traditional"
}

fixedPayload := Payload{
"v": metadata.Release,
"kv": kongVersion,
"db": kongDB,
"rf": routerFlavor,
"id": instanceIDProvider.GetID(), // universal unique identifier for this system
}

Expand Down
8 changes: 5 additions & 3 deletions test/envtest/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ func TestTelemetry(t *testing.T) {
waitTime = 3 * time.Second
tickTime = 10 * time.Millisecond
)
require.Eventually(t, func() bool {
require.Eventuallyf(t, func() bool {
select {
case report := <-reportChan:
return verifyTelemetryReport(t, k8sVersion, string(report))
case <-time.After(tickTime):
return false
}
}, waitTime, tickTime)
}, waitTime, tickTime, "telemetry report never matched expected value")
}

func configForEnvTestTelemetry(t *testing.T, envcfg *rest.Config, splunkEndpoint string, telemetryPeriod time.Duration) manager.Config {
Expand Down Expand Up @@ -340,7 +340,8 @@ func verifyTelemetryReport(t *testing.T, k8sVersion *version.Info, report string
for _, s := range []string{"id", "uptime"} {
report, err = removeStanzaFromReport(report, s)
if err != nil {
t.Logf("failed to remove stanza %q from report: %s", s, err)
// this normally happens during shutdown, when the report is an empty string
// no point in proceeding if so
return false
}
}
Expand All @@ -361,6 +362,7 @@ func verifyTelemetryReport(t *testing.T, k8sVersion *version.Info, report string
"feature-rewriteuris=false;"+
"hn=%s;"+
"kv=3.3.0;"+
"rf=traditional;"+
"v=NOT_SET;"+
"k8s_arch=%s;"+
"k8s_provider=UNKNOWN;"+
Expand Down

0 comments on commit ebb2c52

Please sign in to comment.