Skip to content
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

Implement telemetry send operation using telemetry plugin #405

Merged
merged 1 commit into from
Jul 20, 2023

Conversation

prkalle
Copy link
Contributor

@prkalle prkalle commented Jul 19, 2023

What this PR does / why we need it

This PR implements telemetry send operation using telemetry plugin

Summary:

  • CLI would use the telemetry plugin to send the metrics to supercollider
  • To avoid latency incurred due to send metrics call,affecting users in every command, telemetry data would be sent only if user opt-in for CEIP and the number of rows in DB is hits a threshold
  • User should set environment variable 'TANZU_CLI_SUPERCOLLIDER_ENVIRONMENT' to "staging" inorder to send the metrics to staging data lake(default is production
  • If user sets TANZU_CLI_SUPERCOLLIDER_ENVIRONMENT to "staging" the "is_internal" metrics would set to true
  • Removed csp_org_id and account_number from the local schema as telemetry plugin would be adding these values as metadata

Which issue(s) this PR fixes

Fixes #

Describe testing done for PR

Build and installed the telemetry plugin locally and performed the below tests

Ran the tanzu plugin search command and tanzu mc get command few times until we hit the send threshold(currently set to 10, but may change). Once the threshold is reached the metrics data in DB data is drained and sent to supercollider

❯ rm ~/.config/tanzu-cli-telemetry/cli_metrics.db
❯ ./bin/tanzu config get &> /dev/null
❯ ./bin/tanzu config get &> /dev/null
❯ ./bin/tanzu config get &> /dev/null
❯ ./bin/tanzu config get &> /dev/null
❯ ./bin/tanzu config get &> /dev/null
❯ ./bin/tanzu config get &> /dev/null
❯ ./bin/tanzu config get &> /dev/null
❯ ./bin/tanzu config get &> /dev/null
❯ ./bin/tanzu config get &> /dev/null

❯ sqlite3 -batch ~/.config/tanzu-cli-telemetry/cli_metrics.db
select * from tanzu_cli_operations;
cli_version|os_name|os_arch|plugin_name|plugin_version|command|cli_id|command_start_ts|command_end_ts|target|name_arg|endpoint|flags|exit_status|is_internal|error
test/e2e/framework/v1.0.0-dev|darwin|amd64|||config get|7dbe3b36-f07b-4206-bd77-0f7728e75cc2|1689803312624|1689803312641|||||0|1|
test/e2e/framework/v1.0.0-dev|darwin|amd64|||config get|7dbe3b36-f07b-4206-bd77-0f7728e75cc2|1689803314361|1689803314375|||||0|1|
test/e2e/framework/v1.0.0-dev|darwin|amd64|||config get|7dbe3b36-f07b-4206-bd77-0f7728e75cc2|1689803315844|1689803315858|||||0|1|
test/e2e/framework/v1.0.0-dev|darwin|amd64|||config get|7dbe3b36-f07b-4206-bd77-0f7728e75cc2|1689803317369|1689803317380|||||0|1|
test/e2e/framework/v1.0.0-dev|darwin|amd64|||config get|7dbe3b36-f07b-4206-bd77-0f7728e75cc2|1689803318940|1689803318951|||||0|1|
test/e2e/framework/v1.0.0-dev|darwin|amd64|||config get|7dbe3b36-f07b-4206-bd77-0f7728e75cc2|1689803320350|1689803320361|||||0|1|
test/e2e/framework/v1.0.0-dev|darwin|amd64|||config get|7dbe3b36-f07b-4206-bd77-0f7728e75cc2|1689803321882|1689803321893|||||0|1|
test/e2e/framework/v1.0.0-dev|darwin|amd64|||config get|7dbe3b36-f07b-4206-bd77-0f7728e75cc2|1689803323300|1689803323310|||||0|1|
test/e2e/framework/v1.0.0-dev|darwin|amd64|||config get|7dbe3b36-f07b-4206-bd77-0f7728e75cc2|1689803325702|1689803325719|||||0|1|

❯ ./bin/tanzu mc get --show-details &> /dev/null

❯ sqlite3 -batch ~/.config/tanzu-cli-telemetry/cli_metrics.db
select count(*) from tanzu_cli_operations;
count(*)
0


Release note

Implement telemetry send operation using telemetry plugin

Additional information

Special notes for your reviewer

pkg/telemetry/client.go Outdated Show resolved Hide resolved
pkg/command/root.go Outdated Show resolved Hide resolved
@prkalle prkalle force-pushed the add/send_metrics branch 2 times, most recently from f34a46b to c1f5849 Compare July 20, 2023 01:19
@prkalle prkalle marked this pull request as ready for review July 20, 2023 01:41
@prkalle prkalle requested a review from a team as a code owner July 20, 2023 01:41
Copy link
Contributor

@anujc25 anujc25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor comment. But overall looks good.

pkg/command/root.go Outdated Show resolved Hide resolved
Copy link
Contributor

@chandrareddyp chandrareddyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks.

- CLI would use the telemetry plugin to send the metrics to supercollider
- To avoid latency incurred due to send metrics call,affecting users in every command, telemetry data would be sent only if user opt-in for CEIP and the number of rows in DB is hits a threshold
- User should set environment variable 'TANZU_CLI_SUPERCOLLIDER_ENVIRONMENT' to "staging" inorder to send the metrics to staging data lake(default is production
- If user sets `TANZU_CLI_SUPERCOLLIDER_ENVIRONMENT` to "staging" the "is_internal" metrics would set to true
- Removed csp_org_id and account_number from the local schema as telemetry plugin would be adding these values as metadata

Signed-off-by: Prem Kumar Kalle <pkalle@vmware.com>
Copy link
Contributor

@anujc25 anujc25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@anujc25 anujc25 merged commit 1d117aa into vmware-tanzu:main Jul 20, 2023
3 checks passed
@marckhouzam marckhouzam added this to the v1.0.0 milestone Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants