Add platform version tracking to telemetry

What does this merge request do and why?

This MR adds platform version tracking to telemetry data.

Currently for macOS it uses sw_vers command to get the version, For other platforms GDK::Machine.platform_version is set to unknown

Closes: #3082 (closed)

How to set up and validate locally

Apart from tests to manually verify the changes I tired to modify the GITLAB_SDK_HOST env to a test webhook url from webhook.site and then ran some gdk command and verified the sent telemetry payload

  1. Checkout the branch

  2. Turn telemetry on with gdk telemetry

  3. export GITLAB_SDK_HOST=https://webhook.site/<unique-test-url-path>

  4. For testing purposes set ANALYTICS_BATCH_SIZE=1 at GDK::Telemetry so that telemetry data is flushed immediately

  5. Run some test gdk commands: gdk status

  6. Check the ue_px query param of received GET HTTP call at the test server at webhook.site

  7. Data is base64 encoded so we need to decode it to get the sent JSON telemetry data: echo "<DATA>" | base64 -d

  8. Output when ran locally:

    echo "        eyJzY2hlbWEiOiJpZ2x1OmNvbS5zbm93cGxvd2FuYWx5dGljcy5zbm93cGxvdy91bnN0cnVjdF9ldmVudC9qc29uc2NoZW1hLzEtMC0wIiwiZGF0YSI6eyJzY2hlbWEiOiJpZ2x1OmNvbS5naXRsYWIvY3VzdG9tX2V2ZW50L2pzb25zY2hlbWEvMS0wLTAiLCJkYXRhIjp7Im5hbWUiOiJGaW5pc2ggc3RhdHVzIFtdIiwicHJvcHMiOnsic2Vzc2lvbl9pZCI6Ijc2NDEyMDQ3LTUxZjgtNDhhZS05YThjLTU1NGYzZDdkYTI0YSIsImVudmlyb25tZW50IjoibmF0aXZlIiwicGxhdGZvcm0iOiJkYXJ3aW4iLCJwbGF0Zm9ybV92ZXJzaW9uIjoiMTUuNiIsImFyY2hpdGVjdHVyZSI6ImFybTY0IiwidmVyc2lvbl9tYW5hZ2VyIjoibWlzZSIsInRlYW1fbWVtYmVyIjpmYWxzZSwiZW5hYmxlZF9zZXJ2aWNlcyI6WyJnaXRsYWItdG9wb2xvZ3ktc2VydmljZSIsImdpdGxhYi13b3JraG9yc2UiLCJyYWlscy1iYWNrZ3JvdW5kLWpvYnMiLCJyZWRpcyIsImdpdGxhYi1odHRwLXJvdXRlciIsInNzaGQiLCJ3ZWJwYWNrIiwicmFpbHMtd2ViIiwicG9zdGdyZXNxbCIsInByYWVmZWN0IiwicHJhZWZlY3QtZ2l0YWx5LTAiXSwiY3B1X2NvdW50IjoxMiwic2FuZGJveCI6eyJlbmFibGVkIjpmYWxzZSwibWFuYWdlZCI6ZmFsc2V9LCJwcmVjb21waWxlZCI6eyJydWJ5Ijp0cnVlfSwicmVsZWFzZSI6eyJzaGEiOiI4ZDI1ODljNCIsImRhdGVfdW5peCI6MTc2Mjc4NTY0OH0sImR1cmF0aW9uIjowLjA5MjE3NjAwMDAwNTU2NTU4fX19fQ==" | base64 -d | jq
    
    {
      "schema": "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
      "data": {
        "schema": "iglu:com.gitlab/custom_event/jsonschema/1-0-0",
        "data": {
          "name": "Finish status []",
          "props": {
            "session_id": "76412047-51f8-48ae-9a8c-554f3d7da24a",
            "environment": "native",
            "platform": "darwin",
            "platform_version": "15.6",
            "architecture": "arm64",
            "version_manager": "mise",
            "team_member": false,
            "enabled_services": [
              "gitlab-topology-service",
              "gitlab-workhorse",
              "rails-background-jobs",
              "redis",
              "gitlab-http-router",
              "sshd",
              "webpack",
              "rails-web",
              "postgresql",
              "praefect",
              "praefect-gitaly-0"
            ],
            "cpu_count": 12,
            "sandbox": {
              "enabled": false,
              "managed": false
            },
            "precompiled": {
              "ruby": true
            },
            "release": {
              "sha": "8d2589c4",
              "date_unix": 1762785648
            },
            "duration": 0.09217600000556558
          }
        }
      }
    }

Impacted categories

The following categories relate to this merge request:

Merge request checklist

  • This MR references an issue describing the change.
  • This change is backward compatible. If not, include steps to communicate to users.
  • Tests added for new functionality. If not, raise an issue to follow-up.
  • Observability added/updated (logging, metrics, tracing).
  • Documentation added/updated.
  • Announcement added for notable changes.
  • gdk doctor test added.
Edited by Harsh Rai

Merge request reports

Loading