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

Clear all the local metrics data when user opt out of CEIP #652

Merged

Conversation

prkalle
Copy link
Contributor

@prkalle prkalle commented Jan 19, 2024

What this PR does / why we need it

This PR add changes to clear all the local metrics data when user opt out of CEIP and CLI will ignore (not store) the metrics.

Which issue(s) this PR fixes

Fixes #

Describe testing done for PR

Initially opted-in for the telemetry and later opted-out and verified the local metrics DB data is cleared.

❯ sqlite3 -batch ~/.config/tanzu-cli-telemetry/cli_metrics.db "select count(*) from tanzu_cli_operations;"
count(*)
0
❯ ./bin/tanzu telemetry cli-usage-analytics update --opt-in
I0118 16:12:52.175949   92176 update.go:70] "successfully opted into CEIP"
I0118 16:12:52.189164   92176 update.go:95] "successfully set CLI telemetry options"
❯ ./bin/tanzu context list --current
  NAME                ISACTIVE  TYPE   PROJECT  SPACE
  prem-ucp-intg-ctx7  true      tanzu

[i] Use '--wide' flag to view additional columns.
❯ ./bin/tanzu context list --current
  NAME                ISACTIVE  TYPE   PROJECT  SPACE
  prem-ucp-intg-ctx7  true      tanzu

[i] Use '--wide' flag to view additional columns.
❯ ./bin/tanzu context list --current
  NAME                ISACTIVE  TYPE   PROJECT  SPACE
  prem-ucp-intg-ctx7  true      tanzu

[i] Use '--wide' flag to view additional columns.
❯ sqlite3 -batch ~/.config/tanzu-cli-telemetry/cli_metrics.db "select count(*) from tanzu_cli_operations;"
count(*)
3
❯ ./bin/tanzu telemetry cli-usage-analytics update --opt-out
I0118 16:13:31.126997   92246 update.go:77] "successfully opted out of CEIP"
I0118 16:13:31.138951   92246 update.go:95] "successfully set CLI telemetry options"
❯ sqlite3 -batch ~/.config/tanzu-cli-telemetry/cli_metrics.db "select count(*) from tanzu_cli_operations;"
count(*)
3
❯ ./bin/tanzu context list --current
  NAME                ISACTIVE  TYPE   PROJECT  SPACE
  prem-ucp-intg-ctx7  true      tanzu

[i] Use '--wide' flag to view additional columns.
❯ sqlite3 -batch ~/.config/tanzu-cli-telemetry/cli_metrics.db "select count(*) from tanzu_cli_operations;"
count(*)
0

Some latency numbers with 6000 rows of metric data existing in local DB and if user opt-out, the metric data is deleted. Also captured the time taken when there are 0 rows in the DB. The latency numbers are in acceptable range.

❯ cp /tmp/test.db $HOME/.config/tanzu-cli-telemetry/cli_metrics.db
❯ sqlite3 -batch ~/.config/tanzu-cli-telemetry/cli_metrics.db "select count(*) from tanzu_cli_operations;"
count(*)
6000

❯ time ./bin/tanzu context list --current
  NAME                ISACTIVE  TYPE   PROJECT  SPACE
  prem-ucp-intg-ctx7  true      tanzu

[i] Use '--wide' flag to view additional columns.
./bin/tanzu context list --current  0.34s user 0.08s system 71% cpu 0.582 total

❯ sqlite3 -batch ~/.config/tanzu-cli-telemetry/cli_metrics.db "select count(*) from tanzu_cli_operations;"
count(*)
0
❯ time ./bin/tanzu context list --current
  NAME                ISACTIVE  TYPE   PROJECT  SPACE
  prem-ucp-intg-ctx7  true      tanzu

[i] Use '--wide' flag to view additional columns.
./bin/tanzu context list --current  0.33s user 0.08s system 70% cpu 0.586 total

Release note

Clear all the local metrics data when user opt out of CEIP

Additional information

Special notes for your reviewer

@prkalle prkalle requested a review from a team as a code owner January 19, 2024 00:15
Copy link
Contributor

@vuil vuil left a comment

Choose a reason for hiding this comment

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

lgtm. I left a small suggestion but it is not blocking

pkg/telemetry/client.go Show resolved Hide resolved
- If user opt out of CEIP CLI would clear all the local metrics data and will not store the metrics.

Signed-off-by: Prem Kumar Kalle <pkalle@vmware.com>
@prkalle prkalle force-pushed the update/telemetry_opt_out_db_cleanup branch from dae3dbe to 35267c9 Compare January 20, 2024 01:41
@prkalle prkalle merged commit beb7fde into vmware-tanzu:main Jan 20, 2024
7 checks passed
@marckhouzam marckhouzam added the kind/feature Categorizes issue or PR as related to a new feature label Jan 22, 2024
@marckhouzam marckhouzam added this to the v1.2.0 milestone Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-not-required kind/feature Categorizes issue or PR as related to a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants