From 0e3d1cbd9f147bcd0a5c6f889bb945ec0bfd5394 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Fri, 12 May 2023 01:36:10 -0700 Subject: [PATCH 1/2] Fix for telemetry --- src/containerapp/azext_containerapp/custom.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/containerapp/azext_containerapp/custom.py b/src/containerapp/azext_containerapp/custom.py index 5045e5bf22a..10ef8b05ded 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -4407,8 +4407,6 @@ def patch_run_interactive(cmd, resource_group_name=None, managed_env=None, show_ if without_unpatchable_results == []: return user_input = input("Do you want to apply all the patch or specify by id? (y/n/id)\n") - if user_input != "n": - telemetry_core.add_extension_event('containerapp', {'Context.Default.AzureCLI.PatchRun': "Ran patch run command"}) return patch_apply(cmd, patchable_check_results, user_input, pack_exec_path) @@ -4434,6 +4432,7 @@ def patch_run(cmd, resource_group_name=None, managed_env=None, show_all=False): def patch_apply(cmd, patch_check_list, method, pack_exec_path): results = [] m = method.strip().lower() + patch_run_count = 0 if m == "y": for patch_check in patch_check_list: if patch_check["id"]: @@ -4445,6 +4444,7 @@ def patch_apply(cmd, patch_check_list, method, pack_exec_path): patch_check["targetImageName"], patch_check["newRunImage"], pack_exec_path)) + patch_run_count+=1 elif m == "n": print("No patch applied.") return @@ -4459,9 +4459,19 @@ def patch_apply(cmd, patch_check_list, method, pack_exec_path): patch_check["targetImageName"], patch_check["newRunImage"], pack_exec_path)) + patch_run_properties = { + 'Context.Default.AzureCLI.PatchRunUserResponse':method, + 'Context.Default.AzureCLI.PatchRunCount':1 + } + telemetry_core.add_extension_event('containerapp', patch_run_properties) return print("Invalid patch method or id.") return + patch_run_properties = { + 'Context.Default.AzureCLI.UserResponse':"yes", + 'Context.Default.AzureCLI.PatchRunCount':patch_run_count + } + telemetry_core.add_extension_event('containerapp', patch_run_properties) return results From b33eaaed9348c04590dcd85161f3a565aac37962 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Fri, 12 May 2023 02:02:46 -0700 Subject: [PATCH 2/2] Added comments --- src/containerapp/azext_containerapp/custom.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/containerapp/azext_containerapp/custom.py b/src/containerapp/azext_containerapp/custom.py index 10ef8b05ded..8cbac644793 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -4432,6 +4432,7 @@ def patch_run(cmd, resource_group_name=None, managed_env=None, show_all=False): def patch_apply(cmd, patch_check_list, method, pack_exec_path): results = [] m = method.strip().lower() + # Track number of times patches were applied successfully. patch_run_count = 0 if m == "y": for patch_check in patch_check_list: @@ -4444,6 +4445,7 @@ def patch_apply(cmd, patch_check_list, method, pack_exec_path): patch_check["targetImageName"], patch_check["newRunImage"], pack_exec_path)) + # Increment patch_run_count with every successful patch. patch_run_count+=1 elif m == "n": print("No patch applied.")