Skip to content

feat(cli): send telemetry events to local file #631

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 129 commits into from
Jul 22, 2025
Merged

Conversation

kaizencc
Copy link
Contributor

@kaizencc kaizencc commented Jun 18, 2025

Introduces two telemetry events: invoke and synth:

Invoke: all cli commands send an invoke event. this event gets sent at the conclusion of the command and includes the entire duration of the command.
Synth: some commands synthesize a cloud assembly (cdk synth, cdk deploy, cdk watch, cdk list, cdk diff). these events also send a synth event that includes the duration of the atomic synthesis function that all commands share.

This PR sends telemetry events to a local file. It does not send to an external endpoint yet.

Example: cdk deploy with no credentials (synth event succeeds, invoke event fails)

--

> cdk deploy MyStack --unstable=telemetry --telemetry-file=my/local/file
[
  {
    "event": {
      "command": {
        "path": [
          "deploy",
          "$STACK1"
        ],
        "parameters": {
          "telemetry-file": "<redacted>",
          "unstable": "<redacted>",
          "verbose": 3,
          "lookups": true,
          "ignore-errors": false,
          "json": false,
          "debug": false,
          "staging": true,
          "notices": true,
          "no-color": false,
          "ci": false,
          "all": false,
          "build-exclude": "<redacted>",
          "import-existing-resources": false,
          "force": false,
          "parameters": "<redacted>",
          "previous-parameters": true,
          "logs": true,
          "concurrency": 1,
          "asset-prebuild": true,
          "ignore-no-stacks": false
        },
        "config": {
          "bags": true,
          "fileNames": true
        }
      },
      "state": "SUCCEEDED",
      "eventType": "SYNTH"
    },
    "identifiers": {
      "installationId": "7cb67dad-250e-46fa-a28f-ea365b604b8d",
      "sessionId": "5f1cf087-44dc-4ba5-8f2b-520a7fbe32b4",
      "telemetryVersion": "1.0",
      "cdkCliVersion": "0.0.0",
      "region": "us-east-1",
      "eventId": "5f1cf087-44dc-4ba5-8f2b-520a7fbe32b4:1",
      "timestamp": "2025-07-11T13:16:49.201Z"
    },
    "environment": {
      "ci": false,
      "os": {
        "platform": "darwin",
        "release": "node"
      },
      "nodeVersion": "v20.19.1"
    },
    "project": {},
    "duration": {
      "total": 4350
    }
  },
  {
    "event": {
      "command": {
        "path": [
          "deploy",
          "$STACK1"
        ],
        "parameters": {
          "telemetry-file": "<redacted>",
          "unstable": "<redacted>",
          "verbose": 3,
          "lookups": true,
          "ignore-errors": false,
          "json": false,
          "debug": false,
          "staging": true,
          "notices": true,
          "no-color": false,
          "ci": false,
          "all": false,
          "build-exclude": "<redacted>",
          "import-existing-resources": false,
          "force": false,
          "parameters": "<redacted>",
          "previous-parameters": true,
          "logs": true,
          "concurrency": 1,
          "asset-prebuild": true,
          "ignore-no-stacks": false
        },
        "config": {
          "bags": true,
          "fileNames": true
        }
      },
      "state": "FAILED",
      "eventType": "INVOKE"
    },
    "identifiers": {
      "installationId": "7cb67dad-250e-46fa-a28f-ea365b604b8d",
      "sessionId": "5f1cf087-44dc-4ba5-8f2b-520a7fbe32b4",
      "telemetryVersion": "1.0",
      "cdkCliVersion": "0.0.0",
      "region": "us-east-1",
      "eventId": "5f1cf087-44dc-4ba5-8f2b-520a7fbe32b4:2",
      "timestamp": "2025-07-11T13:16:49.385Z"
    },
    "environment": {
      "ci": false,
      "os": {
        "platform": "darwin",
        "release": "node"
      },
      "nodeVersion": "v20.19.1"
    },
    "project": {},
    "duration": {
      "total": 4609
    },
    "error": {
      "name": "ExpiredToken"
    }
  }
]

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team June 18, 2025 21:53
@github-actions github-actions bot added the p2 label Jun 18, 2025
@kaizencc kaizencc changed the base branch from main to conroy/basic-telemetry-client June 18, 2025 22:05
@kaizencc kaizencc changed the title feat(cli): telemetry for list chore(cli): telemetry for list Jun 18, 2025
@kaizencc kaizencc temporarily deployed to integ-approval July 22, 2025 20:22 — with GitHub Actions Inactive
Signed-off-by: github-actions <github-actions@github.com>
@kaizencc kaizencc dismissed mrgrain’s stale review July 22, 2025 20:57

@mrgrain and i have touched base off line and there are no blockers to launch this feature.

@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue Jul 22, 2025
Merged via the queue into main with commit a6755f0 Jul 22, 2025
27 checks passed
@aws-cdk-automation aws-cdk-automation deleted the conroy/list branch July 22, 2025 21:05
github-merge-queue bot pushed a commit that referenced this pull request Jul 23, 2025
Extension on #631 to provide deploy telemetry events.

---
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license

---------

Signed-off-by: github-actions <github-actions@github.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Eli Polonsky <epolon@amazon.com>
Co-authored-by: Eli Polonsky <Eli.polonsky@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants