-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added telemetries * Updating reference values * Updated code as per review comments * Adding a text message before force removing application package * Modified code as per review comments * re-factor telemetry to common code and re-use across all SF tasks * make.json changes * PR comments # Conflicts: # Tasks/ServiceFabricDeployV1/task.json # Tasks/ServiceFabricDeployV1/task.loc.json
- Loading branch information
1 parent
3a2159d
commit 471aeee
Showing
23 changed files
with
258 additions
and
79 deletions.
There are no files selected for viewing
93 changes: 67 additions & 26 deletions
93
Tasks/Common/Deployment/TelemetryHelper/TelemetryHelper.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,79 @@ | ||
# Telemetry Codes | ||
$telemetryCodes = | ||
$telemetryCodes = | ||
@{ | ||
"Input_Validation" = "Input_Validation_Error"; | ||
"Task_InternalError" = "Task_Internal_Error"; | ||
"DTLSDK_Error" = "Dtl_Sdk_Error"; | ||
} | ||
"Input_Validation" = "Input_Validation_Error"; | ||
"Task_InternalError" = "Task_Internal_Error"; | ||
"DTLSDK_Error" = "Dtl_Sdk_Error"; | ||
} | ||
|
||
# Telemetry Write Method | ||
# Telemetry Write Method | ||
function Write-Telemetry | ||
{ | ||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory=$True,Position=1)] | ||
[string]$codeKey, | ||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory = $True, Position = 1)] | ||
[string]$codeKey, | ||
|
||
[Parameter(Position = 2)] | ||
[string]$errorMsg | ||
) | ||
|
||
$erroCodeMsg = $telemetryCodes[$codeKey] | ||
|
||
## If no error is passed mark it as not available | ||
if ([string]::IsNullOrEmpty($errorMsg)) | ||
{ | ||
$errorMsg = "No error details available" | ||
} | ||
|
||
$errorCode = @{ | ||
$erroCodeMsg = $errorMsg | ||
} | ||
|
||
[Parameter(Position=2)] | ||
[string]$errorMsg | ||
## Form errorcode as json string | ||
$erroCode = ConvertTo-Json -InputObject $errorCode -Compress | ||
$telemetryString = "##vso[task.logissue type=error;code=" + $erroCode + ";]" | ||
Write-Host $telemetryString | ||
} | ||
|
||
function Get-ExceptionData | ||
{ | ||
param( | ||
[System.Management.Automation.ErrorRecord] | ||
$error | ||
) | ||
|
||
$erroCodeMsg = $telemetryCodes[$codeKey] | ||
|
||
## If no error is passed mark it as not available | ||
if([string]::IsNullOrEmpty($errorMsg)) | ||
{ | ||
$errorMsg = "No error details available" | ||
} | ||
$erroCode = ('"{0}":{1}' -f $erroCodeMsg, $errorMsg) | ||
## Form errorcode as json string | ||
$erroCode = '{' + $erroCode + '}' | ||
|
||
$telemetryString = "##vso[task.logissue type=error;code=" + $erroCode + ";]" | ||
Write-Host $telemetryString | ||
|
||
$exceptionData = "" | ||
try | ||
{ | ||
$src = $error.InvocationInfo.PSCommandPath + "|" + $error.InvocationInfo.ScriptLineNumber | ||
$exceptionTypes = "" | ||
|
||
$exception = $error.Exception | ||
if ($exception.GetType().Name -eq 'AggregateException') | ||
{ | ||
$flattenedException = ([System.AggregateException]$exception).Flatten() | ||
$flattenedException.InnerExceptions | ForEach-Object { | ||
$exceptionTypes += $_.GetType().FullName + ";" | ||
} | ||
} | ||
else | ||
{ | ||
do | ||
{ | ||
$exceptionTypes += $exception.GetType().FullName + ";" | ||
$exception = $exception.InnerException | ||
} while ($exception -ne $null) | ||
} | ||
$exceptionData = "$exceptionTypes|$src" | ||
} | ||
catch | ||
{} | ||
|
||
return $exceptionData | ||
} | ||
|
||
# Export only the public function. | ||
Export-ModuleMember -Function Write-Telemetry | ||
Export-ModuleMember -Function Get-ExceptionData | ||
Export-ModuleMember -Variable telemetryCodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
$SF_Operations = @{ | ||
Undefined = 'Undefined'; | ||
ConnectCluster = 'ConnectCluster'; | ||
ConnectClusterMetadata = 'ConnectClusterMetadata'; | ||
TestClusterConnection = 'TestApplicationPackage'; | ||
TestApplicationPackage = 'TestApplicationPackage'; | ||
GetApplication = 'GetApplication'; | ||
GetApplicationType = 'GetApplicationType'; | ||
GetClusterManifest = 'GetClusterManifest'; | ||
RemoveApplication = 'RemoveApplication'; | ||
UnregisterApplicationType = 'UnregisterApplicationType'; | ||
CopyApplicationPackage = 'CopyApplicationPackage'; | ||
RegisterApplicationType = 'RegisterApplicationType'; | ||
RemoveApplicationPackage = 'RemoveApplicationPackage'; | ||
CreateNewApplication = 'CreateNewApplication' | ||
StartApplicationUpgrade = 'StartApplicationUpgrade'; | ||
GetApplicationUpgradeStatus = 'GetApplicationUpgradeStatus'; | ||
EncryptServiceFabricText = 'EncryptServiceFabricText'; | ||
CreateDiffPackage = 'CreateDiffPackage'; | ||
GetComposeDeploymentStatus = 'GetComposeDeploymentStatus'; | ||
RemoveComposeDeployment = 'RemoveComposeDeployment'; | ||
GetComposeDeploymentUpgradeStatus = 'GetComposeDeploymentUpgradeStatus'; | ||
StartComposeDeploymentUpgrade = 'StartComposeDeploymentUpgrade'; | ||
CreateNewComposeDeployment = 'CreateNewComposeDeployment' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
"version": { | ||
"Major": 0, | ||
"Minor": 3, | ||
"Patch": 0 | ||
"Patch": 1 | ||
}, | ||
"demands": [ | ||
"Cmd" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
"version": { | ||
"Major": 0, | ||
"Minor": 3, | ||
"Patch": 0 | ||
"Patch": 1 | ||
}, | ||
"demands": [ | ||
"Cmd" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.