Skip to content

Commit f50d4df

Browse files
feature: (WIP) add new telemetry field
1 parent bc15429 commit f50d4df

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

.vscode/launch.json

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"configurations": [
44
{
55
"name": "Azure CLI Debug (Integrated Console)",
6-
"type": "python",
6+
"type": "debugpy",
77
"request": "launch",
88
"python": "${command:python.interpreterPath}",
99
"program": "${workspaceRoot}/src/azure-cli/azure/cli/__main__.py",
@@ -12,46 +12,32 @@
1212
"--help"
1313
],
1414
"console": "integratedTerminal",
15-
"debugOptions": [
16-
"WaitOnAbnormalExit",
17-
"WaitOnNormalExit",
18-
"RedirectOutput"
19-
],
2015
"justMyCode": false
2116
},
2217
{
2318
"name": "Azure CLI Debug (External Console)",
24-
"type": "python",
19+
"type": "debugpy",
2520
"request": "launch",
2621
"stopOnEntry": true,
2722
"python": "${command:python.interpreterPath}",
2823
"program": "${workspaceRoot}/src/azure-cli/azure/cli/__main__.py",
2924
"cwd": "${workspaceRoot}",
3025
"args": [
31-
"--help"
26+
"VERSION"
3227
],
33-
"console": "externalTerminal",
34-
"debugOptions": [
35-
"WaitOnAbnormalExit",
36-
"WaitOnNormalExit"
37-
]
28+
"console": "externalTerminal"
3829
},
3930
{
4031
"name": "Azdev Scripts",
41-
"type": "python",
32+
"type": "debugpy",
4233
"request": "launch",
4334
"python": "${command:python.interpreterPath}",
4435
"program": "${workspaceRoot}/tools/automation/__main__.py",
4536
"cwd": "${workspaceRoot}",
4637
"args": [
4738
"--help"
4839
],
49-
"console": "integratedTerminal",
50-
"debugOptions": [
51-
"WaitOnAbnormalExit",
52-
"WaitOnNormalExit",
53-
"RedirectOutput"
54-
]
40+
"console": "integratedTerminal"
5541
}
5642
]
57-
}
43+
}

src/azure-cli-core/azure/cli/core/commands/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,9 @@ def execute(self, args):
514514
EVENT_INVOKER_PRE_CMD_TBL_TRUNCATE, EVENT_INVOKER_PRE_LOAD_ARGUMENTS, EVENT_INVOKER_POST_LOAD_ARGUMENTS)
515515

516516
# TODO: Can't simply be invoked as an event because args are transformed
517+
# what are args before this call?
517518
args = _pre_command_table_create(self.cli_ctx, args)
519+
raw_args = args.copy()
518520

519521
self.cli_ctx.raise_event(EVENT_INVOKER_PRE_CMD_TBL_CREATE, args=args)
520522
self.commands_loader.load_command_table(args)
@@ -578,8 +580,10 @@ def execute(self, args):
578580
self.help.show_welcome(subparser)
579581

580582
# TODO: No event in base with which to target
581-
telemetry.set_command_details('az')
583+
telemetry.set_command_details('az', raw_args=raw_args)
582584
telemetry.set_success(summary='welcome')
585+
# @TODO: can add custom telemetry calls here?
586+
# @ie: set commandAsTyped. trigger table? (where does that come from)
583587
return CommandResultItem(None, exit_code=0)
584588

585589
if args[0].lower() == 'help':
@@ -631,9 +635,12 @@ def execute(self, args):
631635
extension_version = get_extension(command_source.extension_name).version
632636
except Exception: # pylint: disable=broad-except
633637
pass
638+
639+
# Raw args added to telemetry payload for command rebuild analysis
634640
telemetry.set_command_details(self.cli_ctx.data['command'], self.data['output'],
635641
self.cli_ctx.data['safe_params'],
636-
extension_name=extension_name, extension_version=extension_version)
642+
extension_name=extension_name, extension_version=extension_version,
643+
raw_args=raw_args)
637644
if extension_name:
638645
self.data['command_extension_name'] = extension_name
639646
self.cli_ctx.logging.log_cmd_metadata_extension_info(extension_name, extension_version)

src/azure-cli-core/azure/cli/core/telemetry.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def __init__(self, correlation_id=None, application=None):
5151
self.feedback = None
5252
self.extension_management_detail = None
5353
self.raw_command = None
54+
self.raw_args = None
5455
self.show_survey_message = False
5556
self.region_input = None
5657
self.region_identified = None
@@ -207,6 +208,7 @@ def _get_azure_cli_properties(self):
207208
set_custom_properties(result, 'InvokeTimeElapsed', str(self.invoke_time_elapsed))
208209
set_custom_properties(result, 'OutputType', self.output_type)
209210
set_custom_properties(result, 'RawCommand', self.raw_command)
211+
set_custom_properties(result, 'RawArgs', ','.join(self.raw_args or []))
210212
set_custom_properties(result, 'Params', ','.join(self.parameters or []))
211213
set_custom_properties(result, 'PythonVersion', platform.python_version())
212214
set_custom_properties(result, 'ModuleCorrelation', self.module_correlation)
@@ -437,12 +439,13 @@ def set_extension_management_detail(ext_name, ext_version):
437439

438440

439441
@decorators.suppress_all_exceptions()
440-
def set_command_details(command, output_type=None, parameters=None, extension_name=None, extension_version=None):
442+
def set_command_details(command, output_type=None, parameters=None, extension_name=None, extension_version=None, raw_args=None):
441443
_session.command = command
442444
_session.output_type = output_type
443445
_session.parameters = parameters
444446
_session.extension_name = extension_name
445447
_session.extension_version = extension_version
448+
_session.raw_args = raw_args
446449

447450

448451
@decorators.suppress_all_exceptions()

0 commit comments

Comments
 (0)