Skip to content

Commit 37e8d56

Browse files
committed
Symfony SDK 5.0.0
1 parent b67f3c9 commit 37e8d56

File tree

4 files changed

+151
-110
lines changed

4 files changed

+151
-110
lines changed

docs/platforms/php/common/configuration/options.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Learn more about [DSN utilization](/product/sentry-basics/dsn-explainer/#dsn-uti
2323

2424
</ConfigKey>
2525

26-
<ConfigKey name="logger" supported={["php", "php.laravel"]} notSupported={["php.symfony"]}>
26+
<ConfigKey name="logger">
2727

2828
If enabled, the SDK prints out debug information about if something went wrong while sending events.
2929
It isn't recommended to use this in production.

docs/platforms/php/guides/symfony/configuration/symfony-options.mdx

Lines changed: 42 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,58 @@ All configuration for Symfony is done in `config/packages/sentry.yaml`.
1515
sentry:
1616
dsn: "___PUBLIC_DSN___"
1717
register_error_listener: true
18+
register_error_handler: true
1819
options:
19-
attach_stacktrace: true
20-
before_breadcrumb: "sentry.callback.before_breadcrumb"
21-
before_send: "sentry.callback.before_send"
22-
capture_silenced_errors: false
23-
context_lines: 5
24-
default_integrations: true
25-
enable_compression: true
26-
environment: "%kernel.environment%"
27-
error_types: "E_ALL & ~E_NOTICE"
28-
http_proxy: "10.0.0.12:3456"
29-
in_app_exclude:
30-
- "%kernel.build_dir%"
31-
- "%kernel.cache_dir%"
32-
- "%kernel.project_dir%/vendor"
3320
integrations:
3421
- "sentry.integration.my_custom_integration"
35-
logger: "php"
36-
max_breadcrumbs: 50
37-
max_value_length: 2048
3822
prefixes:
3923
- "/local_dir/"
40-
release: "abcde12345"
4124
sample_rate: 1
42-
traces_sample_rate: 0
25+
enable_tracing: true
26+
traces_sample_rate: 1
4327
traces_sampler: "sentry.callback.traces_sampler"
44-
send_attempts: 3
45-
send_default_pii: false
46-
server_name: "www.example.com"
28+
attach_stacktrace: true
29+
attach_metric_code_locations: true
30+
context_lines: 5
31+
environment: "%kernel.environment%"
32+
logger: "php"
33+
spotlight: true
34+
spotlight_url: "http://localhost:8969"
35+
release: "5.0.x-dev"
36+
server_name: "localhost"
37+
ignore_exceptions:
38+
- "Symfony\Component\HttpKernel\Exception\BadRequestHttpException"
39+
ignore_transactions:
40+
- "GET /helath"
41+
before_send: "sentry.callback.before_send"
42+
before_send_transaction: "sentry.callback.before_send_transaction"
43+
trace_propagation_targets:
44+
- 'example.com'
4745
tags:
4846
tag1: "value1"
4947
tag2: "value2"
48+
error_types: "E_ALL & ~E_NOTICE"
49+
max_breadcrumbs: 50
50+
before_breadcrumb: "sentry.callback.before_breadcrumb"
51+
in_app_exclude:
52+
- '%kernel.cache_dir%'
53+
in_app_include:
54+
- '%kernel.project_dir%'
55+
send_default_pii: true
56+
max_value_length: 1024
57+
transport: "sentry.transport"
58+
transport: "sentry.http_client"
59+
http_proxy: "proxy.example.com:8080"
60+
http_proxy_authentication: "user:password"
61+
http_connect_timeout: 15
62+
http_timeout: 10
63+
http_ssl_verify_peer: true
64+
http_compression: true
65+
capture_silenced_errors: true
66+
max_request_body_size: "medium"
67+
class_serializers:
68+
App\User: "App\Sentry\Serializer\UserSerializer"
69+
5070
```
5171

5272
The DSN option is the only required option: it sets the Sentry DSN, and so reports all events to the related project. If it's
@@ -106,29 +126,3 @@ class Sentry
106126
}
107127
}
108128
```
109-
110-
## Exclude Some Exceptions
111-
112-
This example shows how to ignore not found exceptions, but you can ignore any exception you want.
113-
114-
1. Declare the integrations:
115-
116-
{/* <!-- prettier-ignore --> */}
117-
```yaml {filename:config/packages/sentry.yaml}
118-
sentry:
119-
options:
120-
integrations:
121-
- 'Sentry\Integration\IgnoreErrorsIntegration'
122-
```
123-
124-
2. Configure the list of ignored exceptions:
125-
126-
{/* <!-- prettier-ignore --> */}
127-
```yaml {filename:config/services.yaml}
128-
services:
129-
Sentry\Integration\IgnoreErrorsIntegration:
130-
arguments:
131-
$options:
132-
ignore_exceptions:
133-
- Symfony\Component\HttpKernel\Exception\NotFoundHttpException
134-
```

docs/platforms/php/guides/symfony/index.mdx

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,9 @@ Install the `sentry/sentry-symfony` bundle:
1414
composer require sentry/sentry-symfony
1515
```
1616

17-
<Note>
18-
19-
Due to a bug in all versions below `6.0` of the [`SensioFrameworkExtraBundle`](https://github.com/sensiolabs/SensioFrameworkExtraBundle) bundle, you will likely receive an error during the execution of the command above related to the missing `Nyholm\Psr7\Factory\Psr17Factory` class. To workaround the issue, if you are not using the PSR-7 bridge, please change the configuration of that bundle as follows:
20-
21-
{/* <!-- prettier-ignore --> */}
22-
```yaml
23-
sensio_framework_extra:
24-
psr_message:
25-
enabled: false
26-
```
27-
28-
For more details about the issue see [https://github.com/sensiolabs/SensioFrameworkExtraBundle/pull/710](https://github.com/sensiolabs/SensioFrameworkExtraBundle/pull/710).
29-
30-
</Note>
31-
3217
## Configure
3318

34-
Add your DSN to `config/packages/sentry.yaml`:
35-
36-
{/* <!-- prettier-ignore --> */}
37-
```yaml {filename:config/packages/sentry.yaml}
38-
sentry:
39-
dsn: "%env(SENTRY_DSN)%"
40-
```
41-
42-
And in your `.env` file:
19+
Add your DSN to your `.env` file:
4320

4421
<SignInNote />
4522

@@ -49,25 +26,6 @@ SENTRY_DSN="___PUBLIC_DSN___"
4926
###< sentry/sentry-symfony ###
5027
```
5128

52-
<Alert level= "warning" title="Performance">
53-
54-
Performance monitoring integrations to support tracing are enabled by default. To use them, update to the latest version of the SDK.
55-
56-
These integrations hook into critical paths of the framework and of the vendors. As a result, there may be a performance penalty. To disable tracing, please see the [Integrations documentation](/platforms/php/guides/symfony/performance/pm-integrations/).
57-
58-
</Alert>
59-
60-
If you **are not** using Symfony Flex, you'll also need to enable the bundle in `config/bundles.php`:
61-
62-
```php {filename:config/bundles.php}
63-
<?php
64-
65-
return [
66-
// ...
67-
Sentry\SentryBundle\SentryBundle::class => ['all' => true],
68-
];
69-
```
70-
7129
### Monolog Integration
7230

7331
If you are using [Monolog](https://github.com/Seldaek/monolog) to report events instead of the typical error listener approach, you need this additional configuration to log the errors correctly:
@@ -86,24 +44,6 @@ monolog:
8644
hub_id: Sentry\State\HubInterface
8745
```
8846
89-
If you are using a version of [MonologBundle](https://github.com/symfony/monolog-bundle) prior to `3.7`, you need to
90-
configure the handler as a service instead:
91-
92-
{/* <!-- prettier-ignore --> */}
93-
```yaml {filename:config/packages/sentry.yaml}
94-
monolog:
95-
handlers:
96-
sentry:
97-
type: service
98-
id: Sentry\Monolog\Handler
99-
100-
services:
101-
Sentry\Monolog\Handler:
102-
arguments:
103-
$hub: '@Sentry\State\HubInterface'
104-
$level: !php/const Monolog\Logger::ERROR
105-
```
106-
10747
Additionally, you can register the `PsrLogMessageProcessor` to resolve PSR-3 placeholders in reported messages:
10848

10949
{/* <!-- prettier-ignore --> */}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
title: Set Up Metrics
3+
description: "Learn how to measure the data points you care about by configuring Metrics in your Symfony app."
4+
---
5+
6+
<Include name="feature-stage-beta-metrics.mdx" />
7+
8+
<Note>
9+
10+
Metrics for Symfony are supported with Sentry Symfony SDK version `5.0.0` and above.
11+
12+
</Note>
13+
14+
Sentry metrics help you pinpoint and solve issues that impact user experience and app performance by measuring the data points that are important to you. You can track things like processing time, event size, user signups, and conversion rates, then correlate them back to tracing data in order to get deeper insights and solve issues faster.
15+
16+
## Emit a Counter
17+
18+
Counters are one of the more basic types of metrics and can be used to count certain event occurrences.
19+
20+
To emit a counter, do the following:
21+
22+
```php
23+
// Increment a counter by one for each button click.
24+
\Sentry\metrics()->increment(
25+
key: 'button_click',
26+
value: 1,
27+
tags: [
28+
'browser' => 'Firefox',
29+
'app_version' => '1.0.0',
30+
],
31+
)
32+
```
33+
34+
## Emit a Distribution
35+
36+
Distributions help you get the most insights from your data by allowing you to obtain aggregations such as `p90`, `min`, `max`, and `avg`.
37+
38+
To emit a distribution, do the following:
39+
40+
```php
41+
// Add '15.0' to a distribution used for tracking the loading times per page.
42+
\Sentry\metrics()->distribution(
43+
key: 'page_load',
44+
value: 15.0,
45+
unit: \Sentry\Metrics\MetricsUnit::millisecond(),
46+
tags: [
47+
'page' => '/home',
48+
],
49+
)
50+
```
51+
52+
## Emit a Set
53+
54+
Sets are useful for looking at unique occurrences and counting the unique elements you added.
55+
56+
To emit a set, do the following:
57+
58+
```php
59+
// Add 'jane' to a set used for tracking the number of users that viewed a page.
60+
\Sentry\metrics()->set(
61+
key: 'user_view',
62+
value: 'jane',
63+
unit: \Sentry\Metrics\MetricsUnit::custom('username'),
64+
tags: [
65+
'page' => '/home',
66+
],
67+
)
68+
```
69+
70+
## Emit a Gauge
71+
72+
Gauges let you obtain aggregates like `min`, `max`, `avg`, `sum`, and `count`. They can be represented in a more space-efficient way than distributions, but they can't be used to get percentiles. If percentiles aren't important to you, we recommend using gauges.
73+
74+
To emit a gauge, do the following:
75+
76+
```php
77+
// Add '15.0' to a gauge used for tracking the loading times for a page.
78+
\Sentry\metrics()->gauge(
79+
key: 'page_load',
80+
value: 15.0,
81+
unit: \Sentry\Metrics\MetricsUnit::millisecond(),
82+
tags: [
83+
'page' => '/home',
84+
],
85+
)
86+
```
87+
88+
## Emit a Timer
89+
90+
Timers can be used to measure the execution time of a specific block of code. They're implemented like distributions, but measured in seconds.
91+
92+
To emit a timer, do the following:
93+
94+
```php
95+
\Sentry\metrics()->timing(
96+
key: 'event_processing_time',
97+
callback: static fn() => process(),
98+
);
99+
```
100+
101+
## Setup Code Locations
102+
103+
To attach the code location of your metrics, set `attach_metric_code_locations` to `true` (the default is `false`).
104+
105+
```yaml {filename:config/packages/sentry.yaml}
106+
attach_metric_code_locations: true
107+
```

0 commit comments

Comments
 (0)