Skip to content

Commit 4076bb2

Browse files
committed
[telemetry] Add new telemetry.data config option for telemetry
Fixes #10766 This PR adds a new `experimental.telemetry.data.platform` config option that is then passed to `GITPOD_INSTALLATION_PLATFORM` env variable, which is then transmitted by the `gitpod-telemetry` job as the `platform` property into our telemetry store. The value of this env variable is then overrided by each install method. This env can have the following values: - `installer` by default as when the installation is done directly through the installer, We don't have enough information about the environment. - [One of the `distribution` values](https://docs.replicated.com/reference/template-functions-static-context#distribution) when done through `kots`. This would have the distribution in which Gitpod is being installed, and is dependent on `kots`. - `local-preview` when the installation is done through the new preview install method. As the changes show in the PR, each installation method overrides the value. Signed-off-by: Tarun Pothulapati <[email protected]>
1 parent 78d09a3 commit 4076bb2

File tree

6 files changed

+35
-4
lines changed

6 files changed

+35
-4
lines changed

components/installation-telemetry/cmd/send.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ var sendCmd = &cobra.Command{
4545
return fmt.Errorf("GITPOD_INSTALLATION_VERSION envvar not set")
4646
}
4747

48+
platform := os.Getenv("GITPOD_INSTALLATION_PLATFORM")
49+
if platform == "" {
50+
return fmt.Errorf("GITPOD_INSTALLATION_PLATFORM envvar not set")
51+
}
52+
4853
client, err := analytics.NewWithConfig(segmentIOToken, analytics.Config{})
4954
defer func() {
5055
err = client.Close()
@@ -54,7 +59,8 @@ var sendCmd = &cobra.Command{
5459
Set("version", versionId).
5560
Set("totalUsers", data.TotalUsers).
5661
Set("totalWorkspaces", data.TotalWorkspaces).
57-
Set("totalInstances", data.TotalInstances)
62+
Set("totalInstances", data.TotalInstances).
63+
Set("platform", platform)
5864

5965
if data.InstallationAdmin.Settings.SendCustomerID {
6066
properties.Set("customerID", data.CustomerID)

gitpod-ws.code-workspace

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
{ "path": "dev/gpctl" },
2626
{ "path": "dev/loadgen" },
2727
{ "path": "dev/poolkeeper" },
28-
{ "path": "install/installer" }
28+
{ "path": "install/installer" },
29+
{ "path": "install/preview" }
2930
],
3031
"settings": {
3132
"typescript.tsdk": "gitpod/node_modules/typescript/lib",

install/installer/pkg/components/gitpod/cronjob.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/gitpod-io/gitpod/installer/pkg/common"
1111
"github.com/gitpod-io/gitpod/installer/pkg/config/v1"
12+
"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"
1213
batchv1 "k8s.io/api/batch/v1"
1314
v1 "k8s.io/api/core/v1"
1415
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -21,6 +22,14 @@ func cronjob(ctx *common.RenderContext) ([]runtime.Object, error) {
2122
return []runtime.Object{}, nil
2223
}
2324

25+
platformTelemetryData := "unknown"
26+
_ = ctx.WithExperimental(func(cfg *experimental.Config) error {
27+
if cfg.Telemetry != nil && cfg.Telemetry.Data.Platform != "" {
28+
platformTelemetryData = cfg.Telemetry.Data.Platform
29+
}
30+
return nil
31+
})
32+
2433
installationTelemetryComponent := fmt.Sprintf("%s-telemetry", Component)
2534

2635
objectMeta := metav1.ObjectMeta{
@@ -63,6 +72,10 @@ func cronjob(ctx *common.RenderContext) ([]runtime.Object, error) {
6372
Name: "GITPOD_INSTALLATION_VERSION",
6473
Value: ctx.VersionManifest.Version,
6574
},
75+
{
76+
Name: "GITPOD_INSTALLATION_PLATFORM",
77+
Value: platformTelemetryData,
78+
},
6679
{
6780
Name: "SERVER_URL",
6881
Value: fmt.Sprintf("http://%s.%s.svc.cluster.local:%d", common.ServerComponent, ctx.Namespace, common.ServerInstallationAdminPort),

install/installer/pkg/config/v1/experimental/experimental.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ type Config struct {
2121
WebApp *WebAppConfig `json:"webapp,omitempty"`
2222
IDE *IDEConfig `json:"ide,omitempty"`
2323
Common *CommonConfig `json:"common,omitempty"`
24+
Telemetry *TelemetryConfig `json:"telemetry,omitempty"`
25+
}
26+
27+
type TelemetryConfig struct {
28+
Data struct {
29+
Platform string `json:"platform"`
30+
} `json:"data"`
2431
}
2532

2633
type CommonConfig struct {

install/kots/manifests/gitpod-installer-job.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ spec:
273273
fi
274274
fi
275275
276+
echo "Gitpod: Update platform telemetry value"
277+
yq eval-all --inplace '.experimental.telemetry.data.platform = "{{repl Distribution }}"' "${CONFIG_FILE}"
278+
276279
echo "Gitpod: Patch Gitpod config"
277280
base64 -d "${CONFIG_PATCH_FILE}" > /tmp/patch.yaml
278281
config_patch=$(cat /tmp/patch.yaml)

install/preview/entrypoint.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ yq e -i '.customCACert.kind = "secret"' config.yaml
105105
yq e -i '.observability.logLevel = "debug"' config.yaml
106106
yq e -i '.workspace.runtime.containerdSocket = "/run/k3s/containerd/containerd.sock"' config.yaml
107107
yq e -i '.workspace.runtime.containerdRuntimeDir = "/var/lib/rancher/k3s/agent/containerd/io.containerd.runtime.v2.task/k8s.io/"' config.yaml
108+
yq e -i '.experimental.telemetry.data.platform = "local-preview"' config.yaml
108109

109110
echo "extracting images to download ahead..."
110-
/gitpod-installer render --config config.yaml | grep 'image:' | sed 's/ *//g' | sed 's/image://g' | sed 's/\"//g' | sed 's/^-//g' | sort | uniq > /gitpod-images.txt
111+
/gitpod-installer render --use-experimental-config --config config.yaml | grep 'image:' | sed 's/ *//g' | sed 's/image://g' | sed 's/\"//g' | sed 's/^-//g' | sort | uniq > /gitpod-images.txt
111112
echo "downloading images..."
112113
while read -r image "$(cat /gitpod-images.txt)"; do
113114
# shellcheck disable=SC2154
@@ -116,7 +117,7 @@ done
116117

117118
ctr images pull "docker.io/gitpod/workspace-full:latest" >/dev/null &
118119

119-
/gitpod-installer render --config config.yaml --output-split-files /var/lib/rancher/k3s/server/manifests/gitpod
120+
/gitpod-installer render --use-experimental-config --config config.yaml --output-split-files /var/lib/rancher/k3s/server/manifests/gitpod
120121

121122
# store files in `gitpod.debug` for debugging purposes
122123
for f in /var/lib/rancher/k3s/server/manifests/gitpod/*.yaml; do (cat "$f"; echo) >> /var/lib/rancher/k3s/server/gitpod.debug; done

0 commit comments

Comments
 (0)