Skip to content

Commit 536433d

Browse files
committed
Merge branch '5.x' into new-scopes
# Conflicts: # src/Logs/LogsAggregator.php # src/Metrics/MetricsAggregator.php # src/SentrySdk.php # src/Tracing/Span.php # src/functions.php # tests/FunctionsTest.php # tests/Logs/LogsAggregatorTest.php # tests/Monolog/LogsHandlerTest.php # tests/State/HubTest.php
2 parents c8e8b3b + 1d0fc51 commit 536433d

22 files changed

+270
-153
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Changelog Preview
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- synchronize
7+
- reopened
8+
- edited
9+
- labeled
10+
- unlabeled
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
changelog-preview:
17+
uses: getsentry/craft/.github/workflows/changelog-preview.yml@v2
18+
secrets: inherit

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ jobs:
2727
- ubuntu-latest
2828
- windows-latest
2929
php:
30-
- { version: '7.2', phpunit: '^8.5.40' }
31-
- { version: '7.3', phpunit: '^9.6.21' }
32-
- { version: '7.4', phpunit: '^9.6.21' }
33-
- { version: '8.0', phpunit: '^9.6.21' }
34-
- { version: '8.1', phpunit: '^9.6.21' }
35-
- { version: '8.2', phpunit: '^9.6.21' }
36-
- { version: '8.3', phpunit: '^9.6.21' }
37-
- { version: '8.4', phpunit: '^9.6.21' }
38-
- { version: '8.5', phpunit: '^9.6.25' }
30+
- { version: '7.2', phpunit: '^8.5.52' }
31+
- { version: '7.3', phpunit: '^9.6.34' }
32+
- { version: '7.4', phpunit: '^9.6.34' }
33+
- { version: '8.0', phpunit: '^9.6.34' }
34+
- { version: '8.1', phpunit: '^9.6.34' }
35+
- { version: '8.2', phpunit: '^9.6.34' }
36+
- { version: '8.3', phpunit: '^9.6.34' }
37+
- { version: '8.4', phpunit: '^9.6.34' }
38+
- { version: '8.5', phpunit: '^9.6.34' }
3939
dependencies:
4040
- lowest
4141
- highest

.github/workflows/publish-release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
steps:
2525
- name: Get auth token
2626
id: token
27-
uses: actions/create-github-app-token@7e473efe3cb98aa54f8d4bac15400b15fad77d94 # v2.2.0
27+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
2828
with:
2929
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
3030
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
@@ -35,7 +35,7 @@ jobs:
3535
fetch-depth: 0
3636

3737
- name: Prepare release
38-
uses: getsentry/action-prepare-release@v1
38+
uses: getsentry/craft@c6e2f04939b6ee67030588afbb5af76b127d8203
3939
env:
4040
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
4141
with:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ package.xml
77
.phpunit.result.cache
88
docs/_build
99
tests/clover.xml
10+
11+
# Local Claude Code settings that should not be committed
12+
.claude/settings.local.json

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
],
3939
'no_whitespace_before_comma_in_array' => false, // Should be dropped when we drop support for PHP 7.x
4040
'stringable_for_to_string' => false,
41+
'modern_serialization_methods' => false, // Could be re-enabled when we drop support for PHP 7.3 and lower
4142
])
4243
->setRiskyAllowed(true)
4344
->setFinder(

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"monolog/monolog": "^1.6|^2.0|^3.0",
3737
"phpbench/phpbench": "^1.0",
3838
"phpstan/phpstan": "^1.3",
39-
"phpunit/phpunit": "^8.5|^9.6",
39+
"phpunit/phpunit": "^8.5.52|^9.6.34",
4040
"vimeo/psalm": "^4.17"
4141
},
4242
"suggest": {

src/HttpClient/HttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function sendRequest(Request $request, Options $options): Response
5757
}
5858

5959
$responseHeaders = [];
60-
$responseHeaderCallback = function ($curlHandle, $headerLine) use (&$responseHeaders): int {
60+
$responseHeaderCallback = static function ($curlHandle, $headerLine) use (&$responseHeaders): int {
6161
return Http::parseResponseHeaders($headerLine, $responseHeaders);
6262
};
6363

src/Monolog/LogsHandler.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class LogsHandler implements HandlerInterface
1818
/**
1919
* The minimum logging level at which this handler will be triggered.
2020
*
21-
* @var LogLevel
21+
* @psalm-suppress UndefinedDocblockClass
22+
*
23+
* @var LogLevel|\Monolog\Level|int
2224
*/
2325
private $logLevel;
2426

@@ -32,21 +34,32 @@ class LogsHandler implements HandlerInterface
3234
/**
3335
* Creates a new Monolog handler that converts Monolog logs to Sentry logs.
3436
*
35-
* @param LogLevel|null $logLevel the minimum logging level at which this handler will be triggered and collects the logs
36-
* @param bool $bubble whether the messages that are handled can bubble up the stack or not
37+
* @psalm-suppress UndefinedDocblockClass
38+
*
39+
* @param LogLevel|\Monolog\Level|int|null $logLevel the minimum logging level at which this handler will be triggered and collects the logs
40+
* @param bool $bubble whether the messages that are handled can bubble up the stack or not
3741
*/
38-
public function __construct(?LogLevel $logLevel = null, bool $bubble = true)
42+
public function __construct($logLevel = null, bool $bubble = true)
3943
{
4044
$this->logLevel = $logLevel ?? LogLevel::debug();
4145
$this->bubble = $bubble;
4246
}
4347

4448
/**
49+
* @psalm-suppress UndefinedDocblockClass
50+
* @psalm-suppress UndefinedClass
51+
*
4552
* @param array<string, mixed>|LogRecord $record
4653
*/
4754
public function isHandling($record): bool
4855
{
49-
return self::getSentryLogLevelFromMonologLevel($record['level'])->getPriority() >= $this->logLevel->getPriority();
56+
if ($this->logLevel instanceof LogLevel) {
57+
return self::getSentryLogLevelFromMonologLevel($record['level'])->getPriority() >= $this->logLevel->getPriority();
58+
} elseif ($this->logLevel instanceof \Monolog\Level) {
59+
return $record['level'] >= $this->logLevel->value;
60+
}
61+
62+
return $record['level'] >= $this->logLevel;
5063
}
5164

5265
/**

src/SentrySdk.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Sentry;
66

7+
use Sentry\Logs\Logs;
8+
use Sentry\Metrics\TraceMetrics;
79
use Sentry\State\Scope;
810
use Sentry\State\ScopeManager;
911
use Sentry\Tracing\SamplingContext;
@@ -274,4 +276,20 @@ private static function isValidSampleRate($sampleRate): bool
274276

275277
return true;
276278
}
279+
280+
/**
281+
* Flushes all buffered telemetry data.
282+
*
283+
* This is a convenience facade that forwards the flush operation to all
284+
* internally managed components.
285+
*
286+
* Calling this method is equivalent to invoking `flush()` on each component
287+
* individually. It does not change flushing behavior, improve performance,
288+
* or reduce the number of network requests.
289+
*/
290+
public static function flush(): void
291+
{
292+
Logs::getInstance()->flush();
293+
TraceMetrics::getInstance()->flush();
294+
}
277295
}

src/Tracing/Span.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public function setStatus(?SpanStatus $status)
299299
*/
300300
public function setHttpStatus(int $statusCode)
301301
{
302-
SentrySdk::configureScope(function (Scope $scope) use ($statusCode) {
302+
SentrySdk::configureScope(static function (Scope $scope) use ($statusCode): void {
303303
$scope->setContext('response', [
304304
'status_code' => $statusCode,
305305
]);

0 commit comments

Comments
 (0)