Skip to content

Commit a82b4f3

Browse files
authored
Merge branch '5.x' into fix-typo
2 parents b6a2ef0 + 5780d2a commit a82b4f3

28 files changed

Lines changed: 545 additions & 1693 deletions

CHANGELOG.md

Lines changed: 3 additions & 557 deletions
Large diffs are not rendered by default.

UPGRADE-5.0.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Upgrade 4.x to 5.0
2+
3+
This guide provides details on how to upgrade from SDK version 4.x to 5.0.
4+
5+
## Breaking Changes
6+
7+
### Metrics API Removed
8+
9+
The entire Metrics API has been removed as it is no longer supported. This includes:
10+
11+
- **Removed classes:**
12+
- `Sentry\Metrics\Metrics`
13+
- `Sentry\Metrics\MetricsUnit`
14+
15+
- **Removed methods:**
16+
- `Event::createMetrics()`
17+
- `Event::getMetrics()` and `Event::setMetrics()`
18+
- `Event::getMetricsSummary()` and `Event::setMetricsSummary()`
19+
- `Span::getMetricsSummary()` and `Span::setMetricsSummary()`
20+
21+
- **Removed functions:**
22+
- `metrics()` - The global metrics function has been removed
23+
24+
- **Removed options:**
25+
- `attach_metric_code_locations` - No longer available in Options
26+
- `before_send_metrics` callback - No longer available in Options
27+
28+
### Deprecated Options Removed
29+
30+
The following deprecated options have been removed from the `Options` class:
31+
32+
- **`enable_tracing`** - Use `traces_sample_rate` or `traces_sampler` instead
33+
```php
34+
// Before (4.x)
35+
$options->setEnableTracing(true);
36+
37+
// After (5.0)
38+
$options->setTracesSampleRate(1.0);
39+
```
40+
41+
- **`spotlight_url`** - Use the `spotlight` option instead
42+
```php
43+
// Before (4.x)
44+
$options->setSpotlightUrl('http://localhost:8969');
45+
46+
// After (5.0)
47+
$options->enableSpotlight('http://localhost:8969');
48+
// or just enable with default URL
49+
$options->enableSpotlight(true);
50+
```
51+
52+
### User Segment Removed
53+
54+
The `segment` property has been removed from the `UserDataBag` class:
55+
56+
```php
57+
// Before (4.x)
58+
$user = new UserDataBag(
59+
id: '123',
60+
email: 'user@example.com',
61+
segment: 'premium' // This parameter is removed
62+
);
63+
64+
// After (5.0)
65+
// Use custom tags or context instead
66+
$user = new UserDataBag(
67+
id: '123',
68+
email: 'user@example.com'
69+
);
70+
$scope->setTag('user_segment', 'premium');
71+
// or
72+
$scope->setContext('user', ['segment' => 'premium']);
73+
```
74+
75+
### Deprecated Methods Removed
76+
77+
The following deprecated methods have been removed:
78+
79+
- **`Span::toW3CTraceparent()`** - Use `Span::toTraceparent()` instead
80+
```php
81+
// Before (4.x)
82+
$traceparent = $span->toW3CTraceparent();
83+
84+
// After (5.0)
85+
$traceparent = $span->toTraceparent();
86+
```
87+
88+
- **`SpanStatus::resourceExchausted()`** (typo) - Use `SpanStatus::resourceExhausted()` instead
89+
- Note: This was a typo fix where the misspelled method `resourceExchausted` was removed
90+
91+
- **`getW3CTraceparent()`** function - Use `getTraceparent()` instead
92+
```php
93+
// Before (4.x)
94+
$traceparent = \Sentry\getW3CTraceparent();
95+
96+
// After (5.0)
97+
$traceparent = \Sentry\getTraceparent();
98+
```
99+
100+
### EventType Changes
101+
102+
The `metrics` event type has been removed from `EventType::cases()` as metrics are no longer supported.

phpstan-baseline.neon

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,6 @@ parameters:
2525
count: 1
2626
path: src/Dsn.php
2727

28-
-
29-
message: "#^Method Sentry\\\\Event\\:\\:getMetrics\\(\\) return type has no value type specified in iterable type array\\.$#"
30-
count: 1
31-
path: src/Event.php
32-
33-
-
34-
message: "#^Method Sentry\\\\Event\\:\\:getMetricsSummary\\(\\) return type has no value type specified in iterable type array\\.$#"
35-
count: 1
36-
path: src/Event.php
37-
38-
-
39-
message: "#^Method Sentry\\\\Event\\:\\:setMetrics\\(\\) has parameter \\$metrics with no value type specified in iterable type array\\.$#"
40-
count: 1
41-
path: src/Event.php
42-
43-
-
44-
message: "#^Method Sentry\\\\Event\\:\\:setMetricsSummary\\(\\) has parameter \\$metricsSummary with no value type specified in iterable type array\\.$#"
45-
count: 1
46-
path: src/Event.php
47-
4828
-
4929
message: "#^Property Sentry\\\\Integration\\\\RequestIntegration\\:\\:\\$options \\(array\\{pii_sanitize_headers\\: array\\<string\\>\\}\\) does not accept array\\.$#"
5030
count: 1
@@ -80,11 +60,6 @@ parameters:
8060
count: 1
8161
path: src/Options.php
8262

83-
-
84-
message: "#^Method Sentry\\\\Options\\:\\:getBeforeSendMetricsCallback\\(\\) should return callable\\(Sentry\\\\Event, Sentry\\\\EventHint\\|null\\)\\: \\(Sentry\\\\Event\\|null\\) but returns mixed\\.$#"
85-
count: 1
86-
path: src/Options.php
87-
8863
-
8964
message: "#^Method Sentry\\\\Options\\:\\:getBeforeSendTransactionCallback\\(\\) should return callable\\(Sentry\\\\Event, Sentry\\\\EventHint\\|null\\)\\: \\(Sentry\\\\Event\\|null\\) but returns mixed\\.$#"
9065
count: 1
@@ -110,11 +85,6 @@ parameters:
11085
count: 1
11186
path: src/Options.php
11287

113-
-
114-
message: "#^Method Sentry\\\\Options\\:\\:getEnableTracing\\(\\) should return bool\\|null but returns mixed\\.$#"
115-
count: 1
116-
path: src/Options.php
117-
11888
-
11989
message: "#^Method Sentry\\\\Options\\:\\:getEnvironment\\(\\) should return string\\|null but returns mixed\\.$#"
12090
count: 1
@@ -230,11 +200,6 @@ parameters:
230200
count: 1
231201
path: src/Options.php
232202

233-
-
234-
message: "#^Method Sentry\\\\Options\\:\\:getSpotlightUrl\\(\\) should return string but returns mixed\\.$#"
235-
count: 1
236-
path: src/Options.php
237-
238203
-
239204
message: "#^Method Sentry\\\\Options\\:\\:getTags\\(\\) should return array\\<string, string\\> but returns mixed\\.$#"
240205
count: 1
@@ -275,11 +240,6 @@ parameters:
275240
count: 1
276241
path: src/Options.php
277242

278-
-
279-
message: "#^Method Sentry\\\\Options\\:\\:shouldAttachMetricCodeLocations\\(\\) should return bool but returns mixed\\.$#"
280-
count: 1
281-
path: src/Options.php
282-
283243
-
284244
message: "#^Method Sentry\\\\Options\\:\\:shouldAttachStacktrace\\(\\) should return bool but returns mixed\\.$#"
285245
count: 1
@@ -310,21 +270,6 @@ parameters:
310270
count: 1
311271
path: src/Tracing/GuzzleTracingMiddleware.php
312272

313-
-
314-
message: "#^Method Sentry\\\\Tracing\\\\Span\\:\\:getMetricsSummary\\(\\) return type has no value type specified in iterable type array\\.$#"
315-
count: 1
316-
path: src/Tracing/Span.php
317-
318-
-
319-
message: "#^Method Sentry\\\\Tracing\\\\Span\\:\\:setMetricsSummary\\(\\) has parameter \\$tags with no value type specified in iterable type array\\.$#"
320-
count: 1
321-
path: src/Tracing/Span.php
322-
323-
-
324-
message: "#^Method Sentry\\\\Tracing\\\\Span\\:\\:setMetricsSummary\\(\\) has parameter \\$value with no type specified\\.$#"
325-
count: 1
326-
path: src/Tracing/Span.php
327-
328273
-
329274
message: "#^Parameter \\#1 \\$email of method Sentry\\\\UserDataBag\\:\\:setEmail\\(\\) expects string\\|null, mixed given\\.$#"
330275
count: 1
@@ -340,11 +285,6 @@ parameters:
340285
count: 1
341286
path: src/UserDataBag.php
342287

343-
-
344-
message: "#^Parameter \\#1 \\$segment of method Sentry\\\\UserDataBag\\:\\:setSegment\\(\\) expects string\\|null, mixed given\\.$#"
345-
count: 1
346-
path: src/UserDataBag.php
347-
348288
-
349289
message: "#^Parameter \\#1 \\$username of method Sentry\\\\UserDataBag\\:\\:setUsername\\(\\) expects string\\|null, mixed given\\.$#"
350290
count: 1

psalm-baseline.xml

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@
88
<code>$parsedDsn['user']</code>
99
</PossiblyUndefinedArrayOffset>
1010
</file>
11-
<file src="src/HttpClient/HttpClientFactory.php">
12-
<UndefinedClass occurrences="5">
13-
<code>Guzzle6HttpClient</code>
14-
<code>GuzzleHttpClientOptions</code>
15-
<code>GuzzleHttpClientOptions</code>
16-
<code>GuzzleHttpClientOptions</code>
17-
<code>SymfonyHttpClient</code>
18-
</UndefinedClass>
19-
</file>
2011
<file src="src/Integration/IntegrationRegistry.php">
2112
<PossiblyInvalidArgument occurrences="2">
2213
<code>$userIntegration</code>
@@ -38,6 +29,14 @@
3829
<code>int|string|Level|LogLevel::*</code>
3930
</UndefinedDocblockClass>
4031
</file>
32+
<file src="src/Monolog/CompatibilityLogLevelTrait.php">
33+
<DuplicateClass occurrences="1">
34+
<code>CompatibilityLogLevelTrait</code>
35+
</DuplicateClass>
36+
<UndefinedClass occurrences="1">
37+
<code>Level</code>
38+
</UndefinedClass>
39+
</file>
4140
<file src="src/Monolog/CompatibilityProcessingHandlerTrait.php">
4241
<DuplicateClass occurrences="1">
4342
<code>CompatibilityProcessingHandlerTrait</code>
@@ -60,6 +59,20 @@
6059
<code>$record['context']</code>
6160
</PossiblyUndefinedMethod>
6261
</file>
62+
<file src="src/Monolog/LogsHandler.php">
63+
<PossiblyInvalidArgument occurrences="3">
64+
<code>$record['level']</code>
65+
<code>$record['level']</code>
66+
<code>$record['message']</code>
67+
</PossiblyInvalidArgument>
68+
<PossiblyInvalidArrayOffset occurrences="1">
69+
<code>$record['context']['exception']</code>
70+
</PossiblyInvalidArrayOffset>
71+
<PossiblyUndefinedMethod occurrences="2">
72+
<code>$record['context']</code>
73+
<code>$record['context']</code>
74+
</PossiblyUndefinedMethod>
75+
</file>
6376
<file src="src/Profiling/Profile.php">
6477
<LessSpecificReturnStatement occurrences="1"/>
6578
<MoreSpecificReturnType occurrences="1">
@@ -79,37 +92,9 @@
7992
<code>representationSerialize</code>
8093
</InvalidReturnType>
8194
</file>
82-
<file src="src/State/Hub.php">
83-
<TooManyArguments occurrences="3">
84-
<code>captureException</code>
85-
<code>captureLastError</code>
86-
<code>captureMessage</code>
87-
</TooManyArguments>
88-
</file>
89-
<file src="src/State/HubAdapter.php">
90-
<TooManyArguments occurrences="4">
91-
<code>captureException</code>
92-
<code>captureLastError</code>
93-
<code>captureMessage</code>
94-
<code>startTransaction</code>
95-
</TooManyArguments>
96-
</file>
97-
<file src="src/Tracing/SpanContext.php">
98-
<UnsafeInstantiation occurrences="1">
99-
<code>new static()</code>
100-
</UnsafeInstantiation>
101-
</file>
10295
<file src="src/Tracing/Transaction.php">
10396
<NonInvariantDocblockPropertyType occurrences="1">
10497
<code>$transaction</code>
10598
</NonInvariantDocblockPropertyType>
10699
</file>
107-
<file src="src/functions.php">
108-
<TooManyArguments occurrences="4">
109-
<code>captureException</code>
110-
<code>captureLastError</code>
111-
<code>captureMessage</code>
112-
<code>startTransaction</code>
113-
</TooManyArguments>
114-
</file>
115100
</files>

src/Event.php

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,6 @@ public static function createLogs(?EventId $eventId = null): self
241241
return new self($eventId, EventType::logs());
242242
}
243243

244-
/**
245-
* @deprecated Metrics are no longer supported. Metrics API is a no-op and will be removed in 5.x.
246-
*/
247-
public static function createMetrics(?EventId $eventId = null): self
248-
{
249-
return new self($eventId, EventType::metrics());
250-
}
251-
252244
/**
253245
* Gets the ID of this event.
254246
*/
@@ -445,38 +437,6 @@ public function setLogs(array $logs): self
445437
return $this;
446438
}
447439

448-
/**
449-
* @deprecated Metrics are no longer supported. Metrics API is a no-op and will be removed in 5.x.
450-
*/
451-
public function getMetrics(): array
452-
{
453-
return [];
454-
}
455-
456-
/**
457-
* @deprecated Metrics are no longer supported. Metrics API is a no-op and will be removed in 5.x.
458-
*/
459-
public function setMetrics(array $metrics): self
460-
{
461-
return $this;
462-
}
463-
464-
/**
465-
* @deprecated Metrics are no longer supported. Metrics API is a no-op and will be removed in 5.x.
466-
*/
467-
public function getMetricsSummary(): array
468-
{
469-
return [];
470-
}
471-
472-
/**
473-
* @deprecated Metrics are no longer supported. Metrics API is a no-op and will be removed in 5.x.
474-
*/
475-
public function setMetricsSummary(array $metricsSummary): self
476-
{
477-
return $this;
478-
}
479-
480440
/**
481441
* Gets the name of the server.
482442
*/

src/EventType.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ public static function logs(): self
4747
return self::getInstance('log');
4848
}
4949

50-
/**
51-
* @deprecated Metrics are no longer supported. Metrics API is a no-op and will be removed in 5.x.
52-
*/
53-
public static function metrics(): self
54-
{
55-
return self::getInstance('metrics');
56-
}
57-
5850
/**
5951
* List of all cases on the enum.
6052
*
@@ -67,7 +59,6 @@ public static function cases(): array
6759
self::transaction(),
6860
self::checkIn(),
6961
self::logs(),
70-
self::metrics(),
7162
];
7263
}
7364

src/Frame.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ final class Frame
1313
{
1414
public const INTERNAL_FRAME_FILENAME = '[internal]';
1515

16-
/**
17-
* @deprecated This constant is deprecated and will be removed in 5.x.
18-
*/
19-
public const ANONYMOUS_CLASS_PREFIX = "class@anonymous\x00";
20-
2116
/**
2217
* @var string|null The name of the function being called
2318
*/

0 commit comments

Comments
 (0)