Skip to content

Commit aef1113

Browse files
aholstrup1Copilot
andauthored
Log AL-Go Action duration to telemetry (#1765)
Log the AL-Go Action duration to telemetry in order to get a better understanding of the performance of actions like RunPipeline over time as well as give an estimate of what the total compute time is for all AL-Go actions in a particular run. --------- Co-authored-by: Copilot <[email protected]>
1 parent fc44206 commit aef1113

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

Actions/Invoke-AlGoAction.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ param(
44
[Parameter(Mandatory = $true)]
55
[scriptblock]$Action,
66
[Parameter(Mandatory = $false)]
7-
[switch]$SkipTelemetry
7+
[switch]$SkipTelemetry,
8+
[Parameter(Mandatory = $false)]
9+
[System.Collections.Generic.Dictionary[[System.String], [System.String]]] $AdditionalData = @{}
810
)
911

1012
$errorActionPreference = "Stop"
@@ -14,15 +16,18 @@ Set-StrictMode -Version 2.0
1416
Import-Module (Join-Path -Path $PSScriptRoot -ChildPath "TelemetryHelper.psm1" -Resolve)
1517

1618
try {
19+
$startTime = Get-Date
1720
Invoke-Command -ScriptBlock $Action
1821

1922
if (-not $SkipTelemetry) {
20-
Trace-Information -ActionName $ActionName
23+
$AdditionalData["ActionDuration"] = (((Get-Date) - $startTime).TotalSeconds).ToString()
24+
Trace-Information -ActionName $ActionName -AdditionalData $AdditionalData
2125
}
2226
}
2327
catch {
2428
if (-not $SkipTelemetry) {
25-
Trace-Exception -ActionName $ActionName -ErrorRecord $_
29+
$AdditionalData["ActionDuration"] = (((Get-Date) - $startTime).TotalSeconds).ToString()
30+
Trace-Exception -ActionName $ActionName -ErrorRecord $_ -AdditionalData $AdditionalData
2631
}
2732

2833
Write-Host "::ERROR::Unexpected error when running action. Error Message: $($_.Exception.Message.Replace("`r",'').Replace("`n",' ')), StackTrace: $($_.ScriptStackTrace.Replace("`r",'').Replace("`n",' <- '))";

RELEASENOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ As stated in [AL-Go Deprecations](https://aka.ms/algodeprecations#cleanModePrepr
1010

1111
- Issue 1697 Error in CheckForUpdates: "Internet Explorer engine is not available" when using self-hosted runners
1212
- Issue 1685 HttpError: Resource not accessible by integration
13+
- Issue 1757 Error when signing apps with key vault signing
1314

1415
### Workflow input validation
1516

@@ -27,6 +28,10 @@ AL-Go for GitHub settings now has a schema. The following line is added at the b
2728

2829
By setting failOn to 'newWarning', pull requests will fail if new warnings are introduced. This feature compares the warnings in the pull request build against those in the latest successful CI/CD build and fails if new warnings are detected.
2930

31+
### AL-Go Telemetry
32+
33+
Now AL-Go telemetry also logs `ActionDuration` which makes it possible to track the duration of the different steps in the AL-Go workflows (e.g. RunPipeline or Sign)
34+
3035
## v7.1
3136

3237
### Issues

Scenarios/EnablingTelemetry.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ Telemetry message: AL-Go action ran
4242

4343
SeverityLevel: 1
4444

45-
Additional Dimensions: None
45+
Additional Dimensions:
46+
| Dimension | Description |
47+
|-----------|-------------|
48+
| ActionDuration | The duration of the action |
4649

4750
### AL-Go action failed
4851

0 commit comments

Comments
 (0)