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

Add metrics to commands being executed #549

Merged
merged 4 commits into from
Aug 17, 2018
Merged

Conversation

lcampos
Copy link
Contributor

@lcampos lcampos commented Aug 9, 2018

What does this PR do?

Adds telemetry for command execution.

What issues does this PR fix or reference?

@W-5280764@

@@ -9,11 +9,13 @@ export class Command {
public readonly command: string;
public readonly description?: string;
public readonly args: string[];
public readonly logName?: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Expanding the command builder to support adding log name when we build the command.

@@ -338,6 +339,10 @@ export abstract class SfdxCommandletExecutor<T>
taskViewService.addCommandExecution(execution, cancellationTokenSource);
}

public logMetric(logName?: string) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

New method that will log command metrics if a logName was declared. Will be "automatically" called if execute is not overwritten, else we'll have to call it from the new execute.

@@ -68,6 +69,7 @@ export class ForceApexLogGetExecutor extends SfdxCommandletExecutor<
cwd: vscode.workspace.rootPath
}).execute(cancellationToken);
this.attachExecution(execution, cancellationTokenSource, cancellationToken);
this.logMetric(execution.command.logName);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Directly calling logMetric since we are not leveraging SfdxCommandletExecutor.

@lcampos lcampos requested review from vazexqi and allileong August 9, 2018 23:06
@lcampos
Copy link
Contributor Author

lcampos commented Aug 9, 2018

There are certain commands we use that are built & executed on the utilities packages that I'm currently not addressing since I didn't want to add a circular dependency because of where we have the telemetryService. E.g. FauxCommandGenerator executes a couple of commands and it is part of salesforcedx-sobject-faux-generator but it is called from forceGenerateFauxClasses, where we do have some level of tracking.

@vazexqi do you have any suggestions for the scenario described above ?

@@ -79,7 +79,8 @@ export class ForceApexTestRunCodeActionExecutor extends SfdxCommandletExecutor<{
.withFlag('--tests', this.test)
.withFlag('--resultformat', 'human')
.withArg('--synchronous')
.withFlag('--loglevel', 'error');
.withFlag('--loglevel', 'error')
.withLogName('force_apex_test_run_codeaction');
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be 'force_apex_test_run_code_action'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, let me change that

@codecov
Copy link

codecov bot commented Aug 10, 2018

Codecov Report

Merging #549 into develop will decrease coverage by 0.17%.
The diff coverage is 38.88%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #549      +/-   ##
===========================================
- Coverage    72.27%   72.09%   -0.18%     
===========================================
  Files          155      155              
  Lines         6128     6157      +29     
  Branches       953      953              
===========================================
+ Hits          4429     4439      +10     
- Misses        1466     1485      +19     
  Partials       233      233
Impacted Files Coverage Δ
...de-core/src/commands/forceApexTestRunCodeAction.ts 69.35% <ø> (ø) ⬆️
...orcedx-vscode-core/src/commands/forceSourcePush.ts 77.77% <ø> (ø) ⬆️
...orcedx-vscode-core/src/commands/forceConfigList.ts 90.9% <ø> (ø) ⬆️
...ackages/salesforcedx-utils-vscode/src/cli/index.ts 100% <ø> (ø) ⬆️
...forcedx-vscode-core/src/commands/forceAliasList.ts 90.9% <ø> (ø) ⬆️
...orcedx-vscode-core/src/commands/forceAuthLogout.ts 71.42% <ø> (ø) ⬆️
...orcedx-vscode-core/src/commands/forceOrgDisplay.ts 66.66% <ø> (ø) ⬆️
...esforcedx-vscode-core/src/commands/forceOrgOpen.ts 80% <ø> (ø) ⬆️
...forcedx-vscode-core/src/commands/forceOrgCreate.ts 90.47% <ø> (ø) ⬆️
...cedx-vscode-core/src/commands/forceSourceDeploy.ts 85.71% <ø> (ø) ⬆️
... and 25 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a7252a...1bb6cce. Read the comment docs.

@lcampos lcampos force-pushed the lcampos/telemetry-commands branch from e21477a to fe3de9c Compare August 15, 2018 18:44
@lcampos lcampos force-pushed the lcampos/telemetry-commands branch from fe3de9c to 1bb6cce Compare August 17, 2018 00:17
@lcampos lcampos requested a review from DatGuyJonathan August 17, 2018 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants