Skip to content

Commit 838cf45

Browse files
committed
# This is a combination of 5 commits.
# This is the 1st commit message: ref: Use constant for the SDK version # This is the commit message #2: docs: Update README.md & CONTRIBUTING.md (#650) * docs: Update README.md & CONTRIBUTING.md * Add slogan # This is the commit message #3: test: Add dsn to e2e test config (#657) * test: Add dsn to e2e test config * Add phpstan exclusion # This is the commit message #4: Fix Symfony 6 deprecations in E2E test (#656) # This is the commit message #5: fix: Update span ops (#655)
1 parent 3314c20 commit 838cf45

File tree

12 files changed

+175
-40
lines changed

12 files changed

+175
-40
lines changed

CONTRIBUTING.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<p align="center">
2+
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
3+
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
4+
</a>
5+
</p>
6+
7+
# Contributing to the Sentry SDK for Symfony
8+
9+
We welcome contributions to `sentry-symfony` by the community.
10+
11+
Please search the [issue tracker](https://github.com/getsentry/sentry-symfony/issues) before creating a new issue (a problem or an improvement request). Please also ask in our [Sentry Community on Discord](https://discord.com/invite/Ww9hbqr) before submitting a new issue. There is a ton of great people in our Discord community ready to help you!
12+
13+
If you feel that you can fix or implement it yourself, please read on to learn how to submit your changes.
14+
15+
## Submitting changes
16+
17+
- Setup the development environment.
18+
- Clone the `sentry-symfony` repository and prepare necessary changes.
19+
- Add tests for your changes to `tests/`.
20+
- Run tests and make sure all of them pass.
21+
- Submit a pull request, referencing any issues it addresses.
22+
- Make sure to update the `CHANGELOG.md` file below the `Unreleased` heading.
23+
24+
We will review your pull request as soon as possible.
25+
Thank you for contributing!
26+
27+
## Development environment
28+
29+
### Clone the repository
30+
31+
```bash
32+
git clone [email protected]:getsentry/sentry-symfony.git
33+
```
34+
35+
Make sure that you have PHP 7.2+ installed. Version 7.4 or higher is required to run style checkers. On macOS, we recommend using brew to install PHP. For Windows, we recommend an official PHP.net release.
36+
37+
### Install the dependencies
38+
39+
Dependencies are managed through [Composer](https://getcomposer.org/):
40+
41+
```bash
42+
composer install
43+
```
44+
45+
### Running tests
46+
47+
Tests can then be run via [PHPUnit](https://phpunit.de/):
48+
49+
```bash
50+
vendor/bin/phpunit
51+
```
52+
53+
## Releasing a new version
54+
55+
(only relevant for Sentry employees)
56+
57+
Prerequisites:
58+
59+
- All changes that should be released must be in the `master` branch.
60+
- Every commit should follow the [Commit Message Format](https://develop.sentry.dev/commit-messages/#commit-message-format) convention.
61+
62+
Manual Process:
63+
64+
- Update CHANGELOG.md with the version to be released. Example commit: https://github.com/getsentry/sentry-symfony/commit/d1d2895c028676113cb191516b80b91abcde31f3.
65+
- On GitHub in the `sentry-symfony` repository go to "Actions" select the "Release" workflow.
66+
- Click on "Run workflow" on the right side and make sure the `master` branch is selected.
67+
- Set "Version to release" input field. Here you decide if it is a major, minor or patch release. (See "Versioning Policy" below)
68+
- Click "Run Workflow"
69+
70+
This will trigger [Craft](https://github.com/getsentry/craft) to prepare everything needed for a release. (For more information see [craft prepare](https://github.com/getsentry/craft#craft-prepare-preparing-a-new-release)) At the end of this process, a release issue is created in the [Publish](https://github.com/getsentry/publish) repository. (Example release issue: https://github.com/getsentry/publish/issues/815)
71+
72+
Now one of the persons with release privileges (most probably your engineering manager) will review this Issue and then add the `accepted` label to the issue.
73+
74+
There are always two persons involved in a release.
75+
76+
If you are in a hurry and the release should be out immediately there is a Slack channel called `#proj-release-approval` where you can see your release issue and where you can ping people to please have a look immediately.
77+
78+
When the release issue is labeled `accepted` [Craft](https://github.com/getsentry/craft) is triggered again to publish the release to all the right platforms. (See [craft publish](https://github.com/getsentry/craft#craft-publish-publishing-the-release) for more information). At the end of this process, the release issue on GitHub will be closed and the release is completed! Congratulations!
79+
80+
There is a sequence diagram visualizing all this in the [README.md](https://github.com/getsentry/publish) of the `Publish` repository.
81+
82+
### Versioning Policy
83+
84+
This project follows [semver](https://semver.org/), with three additions:
85+
86+
- Semver says that major version `0` can include breaking changes at any time. Still, it is common practice to assume that only `0.x` releases (minor versions) can contain breaking changes while `0.x.y` releases (patch versions) are used for backwards-compatible changes (bugfixes and features). This project also follows that practice.
87+
88+
- All undocumented APIs are considered internal. They are not part of this contract.
89+
90+
- Certain features (e.g. integrations) may be explicitly called out as "experimental" or "unstable" in the documentation. They come with their own versioning policy described in the documentation.
91+
92+
We recommend pinning your version requirements against `1.x.*` or `1.x.y`.
93+
Either one of the following is fine:
94+
95+
```json
96+
"sentry/sentry": "^1.0",
97+
"sentry/sentry": "^1",
98+
```
99+
100+
A major release `N` implies the previous release `N-1` will no longer receive updates. We generally do not backport bugfixes to older versions unless they are security relevant. However, feel free to ask for backports of specific commits on the bug tracker.
101+
102+
## Commit message format guidelines
103+
104+
See the documentation on commit messages here:
105+
106+
https://develop.sentry.dev/commit-messages/#commit-message-format

README.md

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,30 @@
44
</a>
55
</p>
66

7-
# sentry-symfony
7+
_Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us [<kbd>**Check out our open positions**</kbd>](https://sentry.io/careers/)_
88

9-
Symfony integration for [Sentry](https://getsentry.com/).
9+
# Official Sentry SDK for Symfony
1010

1111
[![Stable release][Last stable image]][Packagist link]
12+
[![License](https://poser.pugx.org/sentry/sentry/license)](https://packagist.org/packages/sentry/sentry)
1213
[![Total Downloads](https://poser.pugx.org/sentry/sentry/downloads)](https://packagist.org/packages/sentry/sentry)
1314
[![Monthly Downloads](https://poser.pugx.org/sentry/sentry/d/monthly)](https://packagist.org/packages/sentry/sentry)
14-
[![License](https://poser.pugx.org/sentry/sentry/license)](https://packagist.org/packages/sentry/sentry)
1515

1616
![CI](https://github.com/getsentry/sentry-symfony/workflows/CI/badge.svg) [![Coverage Status][Master Code Coverage Image]][Master Code Coverage]
1717
[![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/cWnMQeA)
1818

19-
## Benefits
19+
This is the official Symfony SDK for [Sentry](https://getsentry.com/).
20+
21+
## Getting Started
2022

21-
Use `sentry-symfony` for:
23+
Using this `sentry-symfony` SDK provides you with the following benefits:
2224

23-
* A fast Sentry setup
24-
* Easy configuration in your Symfony app
25-
* Automatic wiring in your app. Each event has the following things added automatically to it:
26-
- user
27-
- Symfony environment
28-
- app path
29-
- excluded paths (cache and vendor)
25+
* Quickly integrate and configure Sentry for your Symfony app
26+
* Out of the box, each event will contain the following data by default
27+
- The currently authenticated user
28+
- The Symfony environment
3029

31-
## Installation
30+
### Install
3231

3332
To install the SDK you will need to be using [Composer]([https://getcomposer.org/)
3433
in your project. To install it please see the [docs](https://getcomposer.org/download/).
@@ -37,7 +36,7 @@ in your project. To install it please see the [docs](https://getcomposer.org/dow
3736
composer require sentry/sentry-symfony
3837
```
3938

40-
If you're using the [Symfony Flex](https://symfony.com/doc/current/setup/flex.html) Composer plugin, it could show a message similar to this:
39+
If you're using the [Symfony Flex](https://symfony.com/doc/current/setup/flex.html) Composer plugin, you might encounter a message similar to this:
4140

4241
```
4342
The recipe for this package comes from the "contrib" repository, which is open to community contributions.
@@ -48,9 +47,8 @@ Do you want to execute this recipe?
4847

4948
Just type `y`, press return, and the procedure will continue.
5049

51-
**Warning:** due to a bug in all versions lower than `6.0` of the [`SensioFrameworkExtra`](https://github.com/sensiolabs/SensioFrameworkExtraBundle) bundle,
52-
if you have it installed you will likely get an error during the execution of the commands above in regards to the missing `Nyholm\Psr7\Factory\Psr17Factory`
53-
class. To workaround the issue, if you are not using the PSR-7 bridge, please change the configuration of that bundle as follows:
50+
**Caution:** Due to a bug in the [`SensioFrameworkExtra`](https://github.com/sensiolabs/SensioFrameworkExtraBundle) bundle, affecting version 6.0 and below, you might run into a missing `Nyholm\Psr7\Factory\Psr17Factory::class` error while executing the commands mentioned above.
51+
If you are not using the PSR-7 bridge, you can work around this issue by changing the configuration of the bundle as follows:
5452

5553
```yaml
5654
sensio_framework_extra:
@@ -60,7 +58,7 @@ sensio_framework_extra:
6058
6159
For more details about the issue see https://github.com/sensiolabs/SensioFrameworkExtraBundle/pull/710.
6260
63-
### Step 2: Enable the Bundle
61+
### Enable the Bundle
6462
6563
If you installed the package using the Flex recipe, the bundle will be automatically enabled. Otherwise, enable it by adding it to the list
6664
of registered bundles in the `Kernel.php` file of your project:
@@ -80,13 +78,16 @@ class AppKernel extends \Symfony\Component\HttpKernel\Kernel
8078
}
8179
```
8280

83-
Note that, unlike before in version 3, the bundle will be enabled in all environments; event reporting, instead, is enabled
84-
only when providing a DSN (see the next step).
81+
The bundle will be enabled in all environments by default.
82+
To enable event reporting, you'll need to add a DSN (see the next step).
8583

86-
## Configuration of the SDK
84+
### Configure
8785

88-
Add your [Sentry DSN](https://docs.sentry.io/quickstart/#configure-the-dsn) value of your project, if you have Symfony 3.4 add it to ``app/config/config_prod.yml`` for Symfony 4 or newer add the value to `config/packages/sentry.yaml`.
89-
Keep in mind that leaving the `dsn` value empty (or undeclared) in other environments will effectively disable Sentry reporting.
86+
Add the [Sentry DSN](https://docs.sentry.io/quickstart/#configure-the-dsn) of your project.
87+
If you're using Symfony 3.4, add the DSN to your `app/config/config_prod.yml` file.
88+
For Symfony 4 or newer, add the DSN to your `config/packages/sentry.yaml` file.
89+
90+
Keep in mind that by leaving the `dsn` value empty (or undeclared), you will disable Sentry's event reporting.
9091

9192
```yaml
9293
sentry:
@@ -105,20 +106,19 @@ the [PHP specific](https://docs.sentry.io/platforms/php/#php-specific-options) o
105106

106107
#### Optional: use custom HTTP factory/transport
107108

108-
Since SDK 2.0 uses HTTPlug to remain transport-agnostic, you need to have installed two packages that provides
109+
Since the SDK 2.0 uses HTTPlug to remain transport-agnostic, you need to install two packages that provide
109110
[`php-http/async-client-implementation`](https://packagist.org/providers/php-http/async-client-implementation)
110111
and [`psr/http-message-implementation`](https://packagist.org/providers/psr/http-message-implementation).
111112

112113
This bundle depends on `sentry/sdk`, which is a metapackage that already solves this need, requiring our suggested HTTP
113114
packages: the Curl client and Guzzle's message factories.
114115

115-
If instead you want to use a different HTTP client or message factory, you can override the ``sentry/sdk`` package adding the following to your ``composer.json`` after the ``require`` section:
116+
Instead, if you want to use a different HTTP client or message factory, you can override the ``sentry/sdk`` package by adding the following to your ``composer.json`` after the ``require`` section:
116117
```json
117118
"replace": {
118119
"sentry/sdk": "*"
119120
}
120121
```
121-
This will prevent the installation of ``sentry/sdk`` package and will allow you to install through Composer the HTTP client or message factory of your choice.
122122

123123
For example for using Guzzle's components:
124124

@@ -154,7 +154,8 @@ sentry:
154154
YourValueObject: 'ValueObjectSerializer'
155155
```
156156

157-
Several serializers can be added and the serializable check is done using **instanceof**. The serializer must implements the `__invoke` method returning an **array** with the information to send to sentry (class name is always sent).
157+
Several serializers can be added and the serializable check is done by using the **instanceof** type operator.
158+
The serializer must implement the `__invoke` method, which needs to return an **array**, containing the information that should be send to Sentry. The class name is always sent by default.
158159

159160
Serializer example:
160161
```php
@@ -169,6 +170,25 @@ final class ValueObjectSerializer
169170
}
170171
```
171172

173+
## Contributing to the SDK
174+
175+
Please refer to [CONTRIBUTING.md](CONTRIBUTING.md).
176+
177+
## Getting help/support
178+
179+
If you need help setting up or configuring the Symfony SDK (or anything else in the Sentry universe) please head over to the [Sentry Community on Discord](https://discord.com/invite/Ww9hbqr). There is a ton of great people in our Discord community ready to help you!
180+
181+
## Resources
182+
183+
- [![Documentation](https://img.shields.io/badge/documentation-sentry.io-green.svg)](https://docs.sentry.io/quickstart/)
184+
- [![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/Ww9hbqr)
185+
- [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](http://stackoverflow.com/questions/tagged/sentry)
186+
- [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry)
187+
188+
## License
189+
190+
Licensed under the Apache 2.0 license, see [`LICENSE`](LICENSE)
191+
172192
[Last stable image]: https://poser.pugx.org/sentry/sentry-symfony/version.svg
173193
[Packagist link]: https://packagist.org/packages/sentry/sentry-symfony
174194
[Master Code Coverage]: https://codecov.io/gh/getsentry/sentry-symfony/branch/master

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ parameters:
1010
- src/aliases.php
1111
excludePaths:
1212
- src/aliases.php
13+
- src/Tracing/Cache/TraceableCacheAdapterForV2.php
14+
- src/Tracing/Cache/TraceableTagAwareCacheAdapterForV2.php
1315
- src/Tracing/Doctrine/DBAL/TracingStatementForV2.php
1416
- src/Tracing/Doctrine/DBAL/TracingDriverForV2.php
1517
- src/Tracing/HttpClient/TraceableHttpClientForV4.php

src/DependencyInjection/SentryExtension.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Sentry\SentryBundle\DependencyInjection;
66

77
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
8-
use Jean85\PrettyVersions;
98
use LogicException;
109
use Psr\Log\NullLogger;
1110
use Sentry\Client;
@@ -140,7 +139,7 @@ private function registerConfiguration(ContainerBuilder $container, array $confi
140139
$clientBuilderDefinition = (new Definition(ClientBuilder::class))
141140
->setArgument(0, new Reference('sentry.client.options'))
142141
->addMethodCall('setSdkIdentifier', [SentryBundle::SDK_IDENTIFIER])
143-
->addMethodCall('setSdkVersion', [PrettyVersions::getVersion('sentry/sentry-symfony')->getPrettyVersion()])
142+
->addMethodCall('setSdkVersion', [SentryBundle::SDK_VERSION])
144143
->addMethodCall('setTransportFactory', [new Reference($config['transport_factory'])])
145144
->addMethodCall('setSerializer', [$serializer])
146145
->addMethodCall('setRepresentationSerializer', [$representationSerializerDefinition])

src/SentryBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ final class SentryBundle extends Bundle
1414
{
1515
public const SDK_IDENTIFIER = 'sentry.php.symfony';
1616

17+
public const SDK_VERSION = '4.3.1';
18+
1719
public function build(ContainerBuilder $container): void
1820
{
1921
parent::build($container);

src/Tracing/Doctrine/DBAL/AbstractTracingStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ abstract class AbstractTracingStatement
1414
/**
1515
* @internal
1616
*/
17-
public const SPAN_OP_STMT_EXECUTE = 'sql.stmt.execute';
17+
public const SPAN_OP_STMT_EXECUTE = 'db.sql.execute';
1818

1919
/**
2020
* @var HubInterface The current hub

src/Tracing/Doctrine/DBAL/TracingDriverConnection.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,32 @@ final class TracingDriverConnection implements TracingDriverConnectionInterface
2323
/**
2424
* @internal
2525
*/
26-
public const SPAN_OP_CONN_PREPARE = 'sql.conn.prepare';
26+
public const SPAN_OP_CONN_PREPARE = 'db.sql.prepare';
2727

2828
/**
2929
* @internal
3030
*/
31-
public const SPAN_OP_CONN_QUERY = 'sql.conn.query';
31+
public const SPAN_OP_CONN_QUERY = 'db.sql.query';
3232

3333
/**
3434
* @internal
3535
*/
36-
public const SPAN_OP_CONN_EXEC = 'sql.conn.exec';
36+
public const SPAN_OP_CONN_EXEC = 'db.sql.exec';
3737

3838
/**
3939
* @internal
4040
*/
41-
public const SPAN_OP_CONN_BEGIN_TRANSACTION = 'sql.conn.begin_transaction';
41+
public const SPAN_OP_CONN_BEGIN_TRANSACTION = 'db.sql.transaction.begin';
4242

4343
/**
4444
* @internal
4545
*/
46-
public const SPAN_OP_TRANSACTION_COMMIT = 'sql.transaction.commit';
46+
public const SPAN_OP_TRANSACTION_COMMIT = 'db.sql.transaction.commit';
4747

4848
/**
4949
* @internal
5050
*/
51-
public const SPAN_OP_TRANSACTION_ROLLBACK = 'sql.transaction.rollback';
51+
public const SPAN_OP_TRANSACTION_ROLLBACK = 'db.sql.transaction.rollback';
5252

5353
/**
5454
* @var HubInterface The current hub

src/Transport/TransportFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
use Http\Client\HttpAsyncClient as HttpAsyncClientInterface;
88
use Http\Discovery\Psr17FactoryDiscovery;
9-
use Jean85\PrettyVersions;
109
use Psr\Http\Message\RequestFactoryInterface;
1110
use Psr\Http\Message\ResponseFactoryInterface;
1211
use Psr\Http\Message\StreamFactoryInterface;
1312
use Psr\Http\Message\UriFactoryInterface;
1413
use Psr\Log\LoggerInterface;
1514
use Sentry\HttpClient\HttpClientFactory;
1615
use Sentry\Options;
16+
use Sentry\SentryBundle\SentryBundle;
1717
use Sentry\Transport\DefaultTransportFactory;
1818
use Sentry\Transport\TransportFactoryInterface;
1919
use Sentry\Transport\TransportInterface;
@@ -52,7 +52,7 @@ public function __construct(
5252
$streamFactory,
5353
$httpClient,
5454
'sentry.php.symfony',
55-
PrettyVersions::getVersion('sentry/sentry-symfony')->getPrettyVersion()
55+
SentryBundle::SDK_VERSION
5656
),
5757
$logger
5858
);

tests/DependencyInjection/SentryExtensionTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Sentry\SentryBundle\Tests\DependencyInjection;
66

77
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
8-
use Jean85\PrettyVersions;
98
use PHPUnit\Framework\TestCase;
109
use Psr\Log\NullLogger;
1110
use Sentry\ClientInterface;
@@ -244,7 +243,7 @@ public function testClientIsCreatedFromOptions(): void
244243

245244
$this->assertCount(6, $methodCalls);
246245
$this->assertDefinitionMethodCallAt($methodCalls[0], 'setSdkIdentifier', [SentryBundle::SDK_IDENTIFIER]);
247-
$this->assertDefinitionMethodCallAt($methodCalls[1], 'setSdkVersion', [PrettyVersions::getVersion('sentry/sentry-symfony')->getPrettyVersion()]);
246+
$this->assertDefinitionMethodCallAt($methodCalls[1], 'setSdkVersion', [SentryBundle::SDK_VERSION]);
248247
$this->assertDefinitionMethodCallAt($methodCalls[2], 'setTransportFactory', [new Reference('App\\Sentry\\Transport\\TransportFactory')]);
249248
$this->assertDefinitionMethodCallAt($methodCalls[5], 'setLogger', [new Reference('app.logger')]);
250249

tests/End2End/App/Kernel.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
4444
$loader->load(__DIR__ . '/deprecations_for_5.yml');
4545
}
4646

47+
if (self::VERSION_ID >= 60000) {
48+
$loader->load(__DIR__ . '/deprecations_for_6.yml');
49+
}
50+
4751
if (interface_exists(MessageBusInterface::class) && self::VERSION_ID >= 40300) {
4852
$loader->load(__DIR__ . '/messenger.yml');
4953
}

0 commit comments

Comments
 (0)