Skip to content

Commit

Permalink
Merge pull request KelvinTegelaar#676 from JohnDuprey/dev
Browse files Browse the repository at this point in the history
Fix function stats
  • Loading branch information
JohnDuprey authored Mar 16, 2024
2 parents 7707162 + 0b2f1e6 commit 195da32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Function Invoke-ListFunctionStats {
}
$Table = Get-CIPPTable -tablename 'CippFunctionStats'

if (!$PartitionKey) { $PartitionKey = 'Queue' }
if (!$PartitionKey) { $PartitionKey = 'Durable' }
if (![string]::IsNullOrEmpty($TenantFilter) -and $TenantFilter -ne 'AllTenants') {
$TenantQuery = " and (tenant eq '{0}' or Tenant eq '{0}' or Tenantid eq '{0}' or tenantid eq '{0}')" -f $TenantFilter
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function Write-CippFunctionStats {
$RowKey = [string](New-Guid).Guid
$TimeSpan = New-TimeSpan -Start $Start -End $End
$Duration = [int]$TimeSpan.TotalSeconds
$DurationMS = [int]$TimeSpan.TotalMilliseconds

$StatEntity = @{}
# Flatten data to json string
Expand All @@ -23,16 +24,18 @@ function Write-CippFunctionStats {
$StatEntity.Start = $Start
$StatEntity.End = $End
$StatEntity.Duration = $Duration
$StatEntity.DurationMS = $DurationMS
$StatEntity.ErrorMsg = $ErrorMsg
$Entity = [PSCustomObject]$Entity
foreach ($Property in $Entity.PSObject.Properties.Name) {
if ($Entity.$Property.GetType().Name -in ('Hashtable', 'PSCustomObject')) {
$StatEntity.$Property = [string]($Entity.$Property | ConvertTo-Json -Compress)
} elseif ($Property -notin ('ETag', 'RowKey', 'PartitionKey', 'Timestamp', 'LastRefresh')) {
$StatEntity.$Property = $Entity.$Property
}
}
$StatsEntity = [PSCustomObject]$StatsEntity
Write-Host ($StatEntity | ConvertTo-Json)
Add-CIPPAzDataTableEntity @Table -Entity $StatsEntity -Force
$StatEntity = [PSCustomObject]$StatEntity
Add-CIPPAzDataTableEntity @Table -Entity $StatEntity -Force
} catch {
Write-Host "Exception logging stats $($_.Exception.Message)"
}
Expand Down

0 comments on commit 195da32

Please sign in to comment.