From d9e66db3e90cb45b75dfc6d3dc23537810dec9a0 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Tue, 10 Feb 2026 15:19:51 +0200 Subject: [PATCH 1/2] Add `Fields` param for `Get-SentryTestLog` func to query additional log items info --- .../Public/Get-SentryLogsByAttribute.ps1 | 22 ++++++++++++++++--- utils/Integration.TestUtils.psm1 | 9 +++++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/sentry-api-client/Public/Get-SentryLogsByAttribute.ps1 b/sentry-api-client/Public/Get-SentryLogsByAttribute.ps1 index 70b0317..fcfec9d 100644 --- a/sentry-api-client/Public/Get-SentryLogsByAttribute.ps1 +++ b/sentry-api-client/Public/Get-SentryLogsByAttribute.ps1 @@ -20,11 +20,18 @@ function Get-SentryLogsByAttribute { .PARAMETER StatsPeriod Relative time period (e.g., '24h', '7d'). Default is '24h'. + .PARAMETER Fields + Additional fields to include in the response. These are merged with default fields + (id, trace, severity, timestamp, message) and the filter attribute. + .EXAMPLE Get-SentryLogsByAttribute -AttributeName 'test_id' -AttributeValue 'integration-test-001' .EXAMPLE Get-SentryLogsByAttribute -AttributeName 'user_id' -AttributeValue '12345' -StatsPeriod '7d' + + .EXAMPLE + Get-SentryLogsByAttribute -AttributeName 'test_id' -AttributeValue 'test-001' -Fields @('sentry.environment', 'custom_attr') #> [CmdletBinding()] param( @@ -38,13 +45,16 @@ function Get-SentryLogsByAttribute { [int]$Limit = 100, [Parameter(Mandatory = $false)] - [string]$StatsPeriod = '24h' + [string]$StatsPeriod = '24h', + + [Parameter(Mandatory = $false)] + [string[]]$Fields ) $Query = "$AttributeName`:$AttributeValue" # Include default fields plus the attribute we're filtering by - $Fields = @( + $DefaultFields = @( 'id', 'trace', 'severity', @@ -53,5 +63,11 @@ function Get-SentryLogsByAttribute { $AttributeName ) - return Get-SentryLogs -Query $Query -Limit $Limit -StatsPeriod $StatsPeriod -Fields $Fields + if ($Fields) { + $AllFields = @($DefaultFields + $Fields) | Select-Object -Unique + } else { + $AllFields = $DefaultFields + } + + return Get-SentryLogs -Query $Query -Limit $Limit -StatsPeriod $StatsPeriod -Fields $AllFields } diff --git a/utils/Integration.TestUtils.psm1 b/utils/Integration.TestUtils.psm1 index 363429a..21ea4b1 100644 --- a/utils/Integration.TestUtils.psm1 +++ b/utils/Integration.TestUtils.psm1 @@ -256,7 +256,10 @@ function Get-SentryTestLog { [int]$TimeoutSeconds = 120, [Parameter()] - [string]$StatsPeriod = '24h' + [string]$StatsPeriod = '24h', + + [Parameter()] + [string[]]$Fields ) Write-Host "Fetching Sentry logs by attribute: $AttributeName=$AttributeValue" -ForegroundColor Yellow @@ -276,7 +279,7 @@ function Get-SentryTestLog { Write-Progress -Activity $progressActivity -Status "Elapsed: $elapsedSeconds/$TimeoutSeconds seconds" -PercentComplete $percentComplete try { - $response = Get-SentryLogsByAttribute -AttributeName $AttributeName -AttributeValue $AttributeValue -StatsPeriod $StatsPeriod + $response = Get-SentryLogsByAttribute -AttributeName $AttributeName -AttributeValue $AttributeValue -StatsPeriod $StatsPeriod -Fields $Fields if ($response.data -and $response.data.Count -ge $ExpectedCount) { $logs = $response.data } @@ -286,7 +289,7 @@ function Get-SentryTestLog { } if ($logs.Count -ge $ExpectedCount) { - Write-Host "Found $($logs.Count) log(s) from Sentry" -ForegroundColor Green + Write-Debug "Found $($logs.Count) log(s) from Sentry" -ForegroundColor Green # Save logs to file for debugging $logsJson = $logs | ConvertTo-Json -Depth 10 From 7aa6a980a1ec546cd9d1ede4186b363e73f2932c Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Tue, 10 Feb 2026 16:08:05 +0200 Subject: [PATCH 2/2] Fix --- utils/Integration.TestUtils.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/Integration.TestUtils.psm1 b/utils/Integration.TestUtils.psm1 index 21ea4b1..94cdf52 100644 --- a/utils/Integration.TestUtils.psm1 +++ b/utils/Integration.TestUtils.psm1 @@ -289,7 +289,7 @@ function Get-SentryTestLog { } if ($logs.Count -ge $ExpectedCount) { - Write-Debug "Found $($logs.Count) log(s) from Sentry" -ForegroundColor Green + Write-Host "Found $($logs.Count) log(s) from Sentry" -ForegroundColor Green # Save logs to file for debugging $logsJson = $logs | ConvertTo-Json -Depth 10