This commit is contained in:
Freddy Kristiansen 2021-11-12 08:04:35 +01:00
Родитель 25376a0e20
Коммит ccf6dca1cb
2 изменённых файлов: 57 добавлений и 2 удалений

Просмотреть файл

@ -31,6 +31,7 @@ function Get-ContainerHelperConfig {
"genericImageName" = 'mcr.microsoft.com/businesscentral:{0}'
"genericImageNameFilesOnly" = 'mcr.microsoft.com/businesscentral:{0}-filesonly'
"usePsSession" = $isAdministrator
"useVolumeForMyFolder" = $false
"use7zipIfAvailable" = $true
"defaultNewContainerParameters" = @{ }
"hostHelperFolder" = "C:\ProgramData\BcContainerHelper"
@ -152,7 +153,26 @@ try {
}
catch {}
$hostHelperFolder = $bcContainerHelperConfig.HostHelperFolder
function VolumeOrPath {
Param(
[string] $path
)
if (!($path.Contains(':') -or $path.Contains('\') -or $path.Contains('/'))) {
$volumes = @(docker volume ls --format "{{.Name}}")
if ($volumes -notcontains $path) {
docker volume create $path
}
$inspect = (docker volume inspect $path) | ConvertFrom-Json
return $inspect.MountPoint
}
else {
return $path
}
}
$bcartifactsCacheFolder = VolumeOrPath $bcContainerHelperConfig.bcartifactsCacheFolder
$hostHelperFolder = VolumeOrPath $bcContainerHelperConfig.HostHelperFolder
$extensionsFolder = Join-Path $hostHelperFolder "Extensions"
$containerHelperFolder = $bcContainerHelperConfig.ContainerHelperFolder
@ -196,6 +216,7 @@ if (!(Test-Path -Path $extensionsFolder -PathType Container)) {
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
. (Join-Path $PSScriptRoot "TelemetryHelper.ps1")
if ($ExportTelemetryFunctions) {
Export-ModuleMember -Function RegisterTelemetryScope
Export-ModuleMember -Function InitTelemetryScope
Export-ModuleMember -Function AddTelemetryProperty
Export-ModuleMember -Function TrackTrace

Просмотреть файл

@ -100,6 +100,38 @@ function AddTelemetryProperty {
}
}
function RegisterTelemetryScope {
Param(
[string] $telemetryScopeJson
)
$telemetryScope = $telemetryScopeJson | ConvertFrom-Json
if ($telemetry.TopId -eq "") {
$telemetry.TopId = $telemetryScope.CorrelationId
}
$scope = @{
"Name" = $telemetryScope.Name
"EventId" = $telemetryScope.eventId
"StartTime" = $telemetryScope.StartTime
"Properties" = [Collections.Generic.Dictionary[string, string]]::new()
"Parameters" = [Collections.Generic.Dictionary[string, string]]::new()
"AllParameters" = [Collections.Generic.Dictionary[string, string]]::new()
"CorrelationId" = $telemetryScope.CorrelationId
"ParentId" = $telemetryScope.CorrelationId
"TopId" = $telemetry.TopId
"Emitted" = $telemetryScope.Emitted
}
"Properties","Parameters","AllParameters" | ForEach-Object {
$prop = $_
$telemetryScope."$prop".PSObject.Properties.GetEnumerator() | ForEach-Object { $scope."$prop".Add($_.Name, $_.Value) }
}
$telemetry.CorrelationId = $telemetryScope.CorrelationId
$scope
}
function InitTelemetryScope {
Param(
[string] $name,
@ -138,7 +170,9 @@ function InitTelemetryScope {
if ($telemetry.Debug) {
Write-Host -ForegroundColor Yellow "Init telemetry scope $name"
}
if ($telemetry.TopId -eq "") { $telemetry.TopId = $CorrelationId }
if ($telemetry.TopId -eq "") {
$telemetry.TopId = $CorrelationId
}
$scope = @{
"Name" = $name
"EventId" = $eventId