Skip to content

Commit 7431223

Browse files
committed
Merge branch 'master' into master-merge
# Conflicts: # composer.json # phpstan-baseline.neon # psalm.xml.dist # src/Event.php # src/EventType.php # src/Metrics/Metrics.php # src/Options.php # src/Tracing/Span.php # src/Unit.php # src/functions.php # tests/Metrics/MetricsTest.php # tests/OptionsTest.php # tests/Serializer/PayloadSerializerTest.php # tests/Serializer/SerializerTest.php
2 parents ce2689b + b4ccc3a commit 7431223

File tree

62 files changed

+2973
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2973
-66
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ jobs:
3535
- { version: '8.2', phpunit: '^9.6.21' }
3636
- { version: '8.3', phpunit: '^9.6.21' }
3737
- { version: '8.4', phpunit: '^9.6.21' }
38+
- { version: '8.5', phpunit: '^9.6.25' }
3839
dependencies:
3940
- lowest
4041
- highest
4142

4243
steps:
4344
- name: Checkout
44-
uses: actions/checkout@v5
45+
uses: actions/checkout@v6
4546
with:
4647
fetch-depth: 2
4748

@@ -60,7 +61,7 @@ jobs:
6061
shell: bash
6162

6263
- name: Cache Composer dependencies
63-
uses: actions/cache@v4
64+
uses: actions/cache@v5
6465
with:
6566
path: ${{ steps.composer-cache.outputs.directory }}
6667
key: ${{ runner.os }}-${{ matrix.php.version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}

.github/workflows/publish-release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ jobs:
2424
steps:
2525
- name: Get auth token
2626
id: token
27-
uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
27+
uses: actions/create-github-app-token@7e473efe3cb98aa54f8d4bac15400b15fad77d94 # v2.2.0
2828
with:
2929
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
3030
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
3131

32-
- uses: actions/checkout@v5
32+
- uses: actions/checkout@v6
3333
with:
3434
token: ${{ steps.token.outputs.token }}
3535
fetch-depth: 0

.github/workflows/static-analysis.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v5
19+
uses: actions/checkout@v6
2020

2121
- name: Setup PHP
2222
uses: shivammathur/setup-php@v2
@@ -34,7 +34,7 @@ jobs:
3434
runs-on: ubuntu-latest
3535
steps:
3636
- name: Checkout
37-
uses: actions/checkout@v5
37+
uses: actions/checkout@v6
3838

3939
- name: Setup PHP
4040
uses: shivammathur/setup-php@v2
@@ -52,7 +52,7 @@ jobs:
5252
runs-on: ubuntu-latest
5353
steps:
5454
- name: Checkout
55-
uses: actions/checkout@v5
55+
uses: actions/checkout@v6
5656

5757
- name: Setup PHP
5858
uses: shivammathur/setup-php@v2

.php-cs-fixer.dist.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
return (new PhpCsFixer\Config())
46
->setRules([
57
'@PHP71Migration' => true,
@@ -35,6 +37,7 @@
3537
'elements' => ['arrays'],
3638
],
3739
'no_whitespace_before_comma_in_array' => false, // Should be dropped when we drop support for PHP 7.x
40+
'stringable_for_to_string' => false,
3841
])
3942
->setRiskyAllowed(true)
4043
->setFinder(

CHANGELOG.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,89 @@
11
# CHANGELOG
22

3+
## 4.19.1
4+
5+
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.19.1.
6+
7+
### Bug Fixes
8+
9+
- Don't cast metrics value to `float` in constructor, drop invalid metrics instead. [(#1981)](https://github.com/getsentry/sentry-php/pull/1981)
10+
11+
## 4.19.0
12+
13+
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.19.0.
14+
15+
### Features
16+
17+
- Add support for metrics. [(#1968)](https://github.com/getsentry/sentry-php/pull/1968)
18+
```php
19+
// Counter metric
20+
\Sentry\trace_metrics()->count('test-counter', 10, ['my-attribute' => 'foo']);
21+
22+
// Gauge metric
23+
\Sentry\trace_metrics()->gauge('test-gauge', 50.0, ['my-attribute' => 'foo'], \Sentry\Unit::millisecond());
24+
25+
// Distribution metric
26+
\Sentry\trace_metrics()->distribution('test-distribution', 20.0, ['my-attribute' => 'foo'], \Sentry\Unit::kilobyte());
27+
28+
// Flush metrics
29+
\Sentry\trace_metrics()->flush();
30+
```
31+
32+
### Bug Fixes
33+
34+
- Add rate limiting for profiles and cron check-ins. [(#1970)](https://github.com/getsentry/sentry-php/pull/1970)
35+
- Fix Spotlight so it always registers the error integrations and emits transport logs even when no DSN is configured. [(#1964)](https://github.com/getsentry/sentry-php/pull/1964)
36+
37+
## 4.18.1
38+
39+
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.18.1.
40+
41+
### Misc
42+
43+
- Add `addFeatureFlag` helper function. [(#1960)](https://github.com/getsentry/sentry-php/pull/1960)
44+
```php
45+
\Sentry\addFeatureFlag("my.feature.enabled", true);
46+
```
47+
48+
## 4.18.0
49+
50+
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.18.0.
51+
52+
### Features
53+
54+
- Add support for feature flags. [(#1951)](https://github.com/getsentry/sentry-php/pull/1951)
55+
```php
56+
\Sentry\SentrySdk::getCurrentHub()->configureScope(function (\Sentry\State\Scope $scope) {
57+
$scope->addFeatureFlag("my.feature.enabled", true);
58+
});
59+
```
60+
- Add more representations for log attributes instead of dropping them. [(#1950)](https://github.com/getsentry/sentry-php/pull/1950)
61+
62+
### Misc
63+
64+
- Merge log attributes in a separate method. [(#1931)](https://github.com/getsentry/sentry-php/pull/1931)
65+
66+
## 4.17.1
67+
68+
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.17.1.
69+
70+
### Misc
71+
72+
- Call `curl_close` only on PHP version 7.4 and below to prevent deprecation warnings. [(#1947)](https://github.com/getsentry/sentry-php/pull/1947)
73+
74+
## 4.17.0
75+
76+
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.17.0.
77+
78+
### Bug Fixes
79+
80+
- Empty strings will no longer display `<encoding error>` when serialized. [(#1940)](https://github.com/getsentry/sentry-php/pull/1940)
81+
82+
### Misc
83+
84+
- Remove `symfony/phpunit-bridge` as a dev dependency. [(#1930)](https://github.com/getsentry/sentry-php/pull/1930)
85+
- Update `sentry.origin` to be consistent with other SDKs. [(#1938)](https://github.com/getsentry/sentry-php/pull/1938)
86+
387
## 4.16.0
488

589
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.16.0.

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ The following integrations are available and maintained by members of the Sentry
6363
- [WordPress](https://wordpress.org/plugins/wp-sentry-integration/)
6464
- Magento 2 by [JustBetter](https://github.com/justbetter/magento2-sentry) or by [Mygento](https://github.com/mygento/module-sentry)
6565
- [Joomla!](https://github.com/AlterBrains/sentry-joomla)
66+
- Neos Flow (and CMS) using [flownative/sentry](https://github.com/flownative/flow-sentry) or [networkteam/sentryclient](https://github.com/networkteam/Networkteam.SentryClient)
67+
- Neos CMS with specific Fusion handling using [networkteam/neos-sentryclient](https://github.com/networkteam/Netwokteam.Neos.SentryClient)
68+
- [TYPO3](https://github.com/networkteam/sentry_client)
6669
- ... feel free to be famous, create a port to your favourite platform!
6770

6871
## 3rd party integrations using the old SDK 3.x
6972

70-
- [Neos Flow](https://github.com/flownative/flow-sentry)
7173
- [ZendFramework](https://github.com/facile-it/sentry-module)
7274
- [Yii2](https://github.com/notamedia/yii2-sentry)
7375
- [Silverstripe](https://github.com/phptek/silverstripe-sentry)
@@ -77,14 +79,11 @@ The following integrations are available and maintained by members of the Sentry
7779

7880
## 3rd party integrations using the old SDK 2.x
7981

80-
- [Neos Flow](https://github.com/networkteam/Networkteam.SentryClient)
8182
- [OXID eShop](https://github.com/OXIDprojects/sentry)
82-
- [TYPO3](https://github.com/networkteam/sentry_client)
8383
- [CakePHP](https://github.com/Connehito/cake-sentry/tree/3.x)
8484

8585
## 3rd party integrations using the old SDK 1.x
8686

87-
- [Neos CMS](https://github.com/networkteam/Netwokteam.Neos.SentryClient)
8887
- [OpenCart](https://github.com/BurdaPraha/oc_sentry)
8988
- [TYPO3](https://github.com/networkteam/sentry_client/tree/2.1.1)
9089

@@ -113,7 +112,7 @@ If you need help setting up or configuring the PHP SDK (or anything else in the
113112
- [![Documentation](https://img.shields.io/badge/documentation-sentry.io-green.svg)](https://docs.sentry.io/quickstart/)
114113
- [![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/Ww9hbqr)
115114
- [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](http://stackoverflow.com/questions/tagged/sentry)
116-
- [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry)
115+
- [![X Follow](https://img.shields.io/twitter/follow/sentry?label=sentry&style=social)](https://x.com/intent/follow?screen_name=sentry)
117116

118117
## License
119118

phpstan-baseline.neon

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ parameters:
2828
count: 1
2929
path: src/Dsn.php
3030

31+
-
32+
message: "#^Method Sentry\\\\Event\\:\\:getMetricsSummary\\(\\) return type has no value type specified in iterable type array\\.$#"
33+
count: 1
34+
path: src/Event.php
35+
36+
-
37+
message: "#^Method Sentry\\\\Event\\:\\:setMetricsSummary\\(\\) has parameter \\$metricsSummary with no value type specified in iterable type array\\.$#"
38+
count: 1
39+
path: src/Event.php
40+
41+
-
42+
message: "#^Property Sentry\\\\Integration\\\\RequestIntegration\\:\\:\\$options \\(array\\{pii_sanitize_headers\\: array\\<string\\>\\}\\) does not accept array\\.$#"
43+
count: 1
44+
path: src/Integration/RequestIntegration.php
45+
3146
-
3247
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
3348
count: 1

src/Attributes/Attribute.php

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

55
namespace Sentry\Attributes;
66

7+
use Sentry\Serializer\SerializableInterface;
8+
use Sentry\Util\JSON;
9+
710
/**
811
* @phpstan-type AttributeType 'string'|'boolean'|'integer'|'double'
912
* @phpstan-type AttributeValue string|bool|int|float
@@ -68,7 +71,7 @@ public static function fromValue($value): self
6871
public static function tryFromValue($value): ?self
6972
{
7073
if ($value === null) {
71-
return null;
74+
return new self('null', 'string');
7275
}
7376

7477
if (\is_bool($value)) {
@@ -83,14 +86,22 @@ public static function tryFromValue($value): ?self
8386
return new self($value, 'double');
8487
}
8588

86-
if (\is_string($value) || (\is_object($value) && method_exists($value, '__toString'))) {
87-
$stringValue = (string) $value;
88-
89-
if (empty($stringValue)) {
90-
return null;
89+
if ($value instanceof SerializableInterface) {
90+
try {
91+
return new self(JSON::encode($value->toSentry()), 'string');
92+
} catch (\Throwable $e) {
93+
// Ignore the exception and continue trying other methods
9194
}
95+
}
96+
97+
if (\is_string($value) || (\is_object($value) && method_exists($value, '__toString'))) {
98+
return new self((string) $value, 'string');
99+
}
92100

93-
return new self($stringValue, 'string');
101+
try {
102+
return new self(JSON::encode($value), 'string');
103+
} catch (\Throwable $e) {
104+
// Ignore the exception
94105
}
95106

96107
return null;

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Client implements ClientInterface
3232
/**
3333
* The version of the SDK.
3434
*/
35-
public const SDK_VERSION = '4.16.0';
35+
public const SDK_VERSION = '4.19.1';
3636

3737
/**
3838
* Regex pattern to detect if a string is a regex pattern (starts and ends with / optionally followed by flags).

src/Event.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Sentry\Context\OsContext;
99
use Sentry\Context\RuntimeContext;
1010
use Sentry\Logs\Log;
11+
use Sentry\Metrics\Types\Metric;
1112
use Sentry\Profiling\Profile;
1213
use Sentry\Tracing\Span;
1314
use Sentry\Util\DebugType;
@@ -73,6 +74,11 @@ final class Event
7374
*/
7475
private $logs = [];
7576

77+
/**
78+
* @var Metric[]
79+
*/
80+
private $metrics = [];
81+
7682
/**
7783
* @var string|null The name of the server (e.g. the host name)
7884
*/
@@ -248,6 +254,11 @@ public static function createLogs(?EventId $eventId = null): self
248254
return new self($eventId, EventType::logs());
249255
}
250256

257+
public static function createMetrics(?EventId $eventId = null): self
258+
{
259+
return new self($eventId, EventType::metrics());
260+
}
261+
251262
/**
252263
* Gets the ID of this event.
253264
*/
@@ -444,6 +455,24 @@ public function setLogs(array $logs): self
444455
return $this;
445456
}
446457

458+
/**
459+
* @return Metric[]
460+
*/
461+
public function getMetrics(): array
462+
{
463+
return $this->metrics;
464+
}
465+
466+
/**
467+
* @param Metric[] $metrics
468+
*/
469+
public function setMetrics(array $metrics): self
470+
{
471+
$this->metrics = $metrics;
472+
473+
return $this;
474+
}
475+
447476
/**
448477
* Gets the name of the server.
449478
*/

0 commit comments

Comments
 (0)