Skip to content

[telemetry] Add new telemetry.data config option for telemetry #10925

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

Merged
merged 1 commit into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion components/installation-telemetry/cmd/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ var sendCmd = &cobra.Command{
return fmt.Errorf("GITPOD_INSTALLATION_VERSION envvar not set")
}

platform := os.Getenv("GITPOD_INSTALLATION_PLATFORM")
if platform == "" {
return fmt.Errorf("GITPOD_INSTALLATION_PLATFORM envvar not set")
}

client, err := analytics.NewWithConfig(segmentIOToken, analytics.Config{})
defer func() {
err = client.Close()
Expand All @@ -54,7 +59,8 @@ var sendCmd = &cobra.Command{
Set("version", versionId).
Set("totalUsers", data.TotalUsers).
Set("totalWorkspaces", data.TotalWorkspaces).
Set("totalInstances", data.TotalInstances)
Set("totalInstances", data.TotalInstances).
Set("platform", platform)

if data.InstallationAdmin.Settings.SendCustomerID {
properties.Set("customerID", data.CustomerID)
Expand Down
3 changes: 2 additions & 1 deletion gitpod-ws.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
{ "path": "dev/changelog" },
{ "path": "dev/gpctl" },
{ "path": "dev/loadgen" },
{ "path": "install/installer" }
{ "path": "install/installer" },
{ "path": "install/preview" }
],
"settings": {
"typescript.tsdk": "gitpod/node_modules/typescript/lib",
Expand Down
13 changes: 13 additions & 0 deletions install/installer/pkg/components/gitpod/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

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

platformTelemetryData := "unknown"
_ = ctx.WithExperimental(func(cfg *experimental.Config) error {
if cfg.Telemetry != nil && cfg.Telemetry.Data.Platform != "" {
platformTelemetryData = cfg.Telemetry.Data.Platform
}
return nil
})

installationTelemetryComponent := fmt.Sprintf("%s-telemetry", Component)

objectMeta := metav1.ObjectMeta{
Expand Down Expand Up @@ -63,6 +72,10 @@ func cronjob(ctx *common.RenderContext) ([]runtime.Object, error) {
Name: "GITPOD_INSTALLATION_VERSION",
Value: ctx.VersionManifest.Version,
},
{
Name: "GITPOD_INSTALLATION_PLATFORM",
Value: platformTelemetryData,
},
{
Name: "SERVER_URL",
Value: fmt.Sprintf("http://%s.%s.svc.cluster.local:%d", common.ServerComponent, ctx.Namespace, common.ServerInstallationAdminPort),
Expand Down
7 changes: 7 additions & 0 deletions install/installer/pkg/config/v1/experimental/experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ type Config struct {
WebApp *WebAppConfig `json:"webapp,omitempty"`
IDE *IDEConfig `json:"ide,omitempty"`
Common *CommonConfig `json:"common,omitempty"`
Telemetry *TelemetryConfig `json:"telemetry,omitempty"`
}

type TelemetryConfig struct {
Data struct {
Platform string `json:"platform"`
} `json:"data"`
}

type CommonConfig struct {
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-installer-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ spec:
fi
fi

echo "Gitpod: Update platform telemetry value"
yq eval-all --inplace '.experimental.telemetry.data.platform = "{{repl Distribution }}"' "${CONFIG_FILE}"

echo "Gitpod: Patch Gitpod config"
base64 -d "${CONFIG_PATCH_FILE}" > /tmp/patch.yaml
config_patch=$(cat /tmp/patch.yaml)
Expand Down
5 changes: 3 additions & 2 deletions install/preview/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ yq e -i '.customCACert.kind = "secret"' config.yaml
yq e -i '.observability.logLevel = "debug"' config.yaml
yq e -i '.workspace.runtime.containerdSocket = "/run/k3s/containerd/containerd.sock"' config.yaml
yq e -i '.workspace.runtime.containerdRuntimeDir = "/var/lib/rancher/k3s/agent/containerd/io.containerd.runtime.v2.task/k8s.io/"' config.yaml
yq e -i '.experimental.telemetry.data.platform = "local-preview"' config.yaml

echo "extracting images to download ahead..."
/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
/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
echo "downloading images..."
while read -r image "$(cat /gitpod-images.txt)"; do
# shellcheck disable=SC2154
Expand All @@ -116,7 +117,7 @@ done

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

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

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