Skip to content

Commit 616cbb6

Browse files
cleptricstayallive
andauthored
Disable storage integration by default (#746)
Co-authored-by: Alex Bouma <[email protected]>
1 parent 6c3e562 commit 616cbb6

File tree

4 files changed

+67
-28
lines changed

4 files changed

+67
-28
lines changed

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
# Changelog
22

3+
## 3.7.1
4+
5+
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v3.7.1.
6+
7+
### Bug Fixes
8+
9+
- Performance traces and breadcrumbs for filesystem access are now turned off by default [(#746)](https://github.com/getsentry/sentry-laravel/pull/746)
10+
11+
To enable the feature, you'll need to make some changes in your `config/filesystems.php` file for each disk where you want to enable the tracing filesystem driver.
12+
13+
```php
14+
// For example, if you want to trace the `local` disk, you update the disk config from this:
15+
'local' => [
16+
'driver' => 'local',
17+
'root' => storage_path('app'),
18+
'throw' => false,
19+
],
20+
21+
// to this:
22+
'local' => [
23+
'driver' => 'sentry',
24+
'root' => storage_path('app'),
25+
'throw' => false,
26+
27+
'sentry_disk_name' => 'local',
28+
'sentry_original_driver' => 'local',
29+
'sentry_enable_spans' => true,
30+
'sentry_enable_breadcrumbs' => true,
31+
],
32+
```
33+
34+
For each disk, you replace the `driver` key with `sentry` and add the `sentry_original_driver` key with the original driver name.
35+
For us to construct the original driver, you also need to add the `sentry_disk_name` key with the name of the disk.
36+
In addition, you can specify the optional `sentry_enable_spans` and `sentry_enable_breadcrumbs` config keys to turn off that feature for the disk.
37+
These options are enabled by default.
38+
39+
Please note that we replace the driver for the disk with a custom driver that will capture performance traces and breadcrumbs.
40+
This means that relying on the disk to be of a specific type might cause problems.
41+
If you rely on the disk being an instance of `Illuminate\Contracts\Filesystem\Filesystem` or `Illuminate\Contracts\Filesystem\Cloud`, there should be no problem.
42+
343
## 3.7.0
444

545
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v3.7.0.

config/sentry.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#traces-sample-rate
2424
'traces_sample_rate' => env('SENTRY_TRACES_SAMPLE_RATE') === null ? null : (float)env('SENTRY_TRACES_SAMPLE_RATE'),
25-
25+
2626
// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#profiles-sample-rate
2727
'profiles_sample_rate' => env('SENTRY_PROFILES_SAMPLE_RATE') === null ? null : (float)env('SENTRY_PROFILES_SAMPLE_RATE'),
2828

@@ -37,13 +37,9 @@
3737
// Capture Laravel cache events (hits, writes etc.) as breadcrumbs
3838
'cache' => env('SENTRY_BREADCRUMBS_CACHE_ENABLED', true),
3939

40-
4140
// Capture Livewire components like routes as breadcrumbs
4241
'livewire' => env('SENTRY_BREADCRUMBS_LIVEWIRE_ENABLED', true),
4342

44-
// Capture storage access as breadcrumbs
45-
'storage' => env('SENTRY_BREADCRUMBS_STORAGE_ENABLED', true),
46-
4743
// Capture SQL queries as breadcrumbs
4844
'sql_queries' => env('SENTRY_BREADCRUMBS_SQL_QUERIES_ENABLED', true),
4945

@@ -77,9 +73,6 @@
7773
// Capture views rendered as spans
7874
'views' => env('SENTRY_TRACE_VIEWS_ENABLED', true),
7975

80-
// Capture storage access as spans
81-
'storage' => env('SENTRY_TRACE_STORAGE_ENABLED', true),
82-
8376
// Capture Livewire components as spans
8477
'livewire' => env('SENTRY_TRACE_LIVEWIRE_ENABLED', true),
8578

src/Sentry/Laravel/Features/Storage/Integration.php

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,12 @@ class Integration extends Feature
1717

1818
public function isApplicable(): bool
1919
{
20-
return $this->isTracingFeatureEnabled(self::FEATURE_KEY)
21-
|| $this->isBreadcrumbFeatureEnabled(self::FEATURE_KEY);
20+
// Since we only register the driver this feature is always applicable
21+
return true;
2222
}
2323

2424
public function setup(): void
2525
{
26-
foreach (config('filesystems.disks') as $disk => $config) {
27-
$currentDriver = $config['driver'];
28-
29-
if ($currentDriver === self::STORAGE_DRIVER_NAME) {
30-
continue;
31-
}
32-
33-
config([
34-
"filesystems.disks.{$disk}.driver" => self::STORAGE_DRIVER_NAME,
35-
"filesystems.disks.{$disk}.sentry_disk_name" => $disk,
36-
"filesystems.disks.{$disk}.sentry_original_driver" => $config['driver'],
37-
]);
38-
}
39-
4026
$this->container()->afterResolving(FilesystemManager::class, function (FilesystemManager $filesystemManager): void {
4127
$filesystemManager->extend(
4228
self::STORAGE_DRIVER_NAME,
@@ -69,8 +55,8 @@ function (Application $application, array $config) use ($filesystemManager): Fil
6955

7056
$defaultData = ['disk' => $disk, 'driver' => $config['driver']];
7157

72-
$recordSpans = $this->isTracingFeatureEnabled(self::FEATURE_KEY);
73-
$recordBreadcrumbs = $this->isBreadcrumbFeatureEnabled(self::FEATURE_KEY);
58+
$recordSpans = $config['sentry_enable_spans'] ?? $this->isTracingFeatureEnabled(self::FEATURE_KEY);
59+
$recordBreadcrumbs = $config['sentry_enable_breadcrumbs'] ?? $this->isBreadcrumbFeatureEnabled(self::FEATURE_KEY);
7460

7561
return $originalFilesystem instanceof CloudFilesystem
7662
? new SentryCloudFilesystem($originalFilesystem, $defaultData, $recordSpans, $recordBreadcrumbs)

test/Sentry/Features/StorageIntegrationTest.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ class StorageIntegrationTest extends TestCase
1010
{
1111
public function testCreatesSpansFor(): void
1212
{
13+
$this->resetApplicationWithConfig([
14+
'filesystems.disks.local.driver' => 'sentry',
15+
'filesystems.disks.local.sentry_disk_name' => 'local',
16+
'filesystems.disks.local.sentry_enable_spans' => true,
17+
'filesystems.disks.local.sentry_original_driver' => 'local',
18+
]);
19+
1320
$hub = $this->getHubFromContainer();
1421

1522
$transaction = $hub->startTransaction(new TransactionContext);
@@ -60,7 +67,10 @@ public function testCreatesSpansFor(): void
6067
public function testDoesntCreateSpansWhenDisabled(): void
6168
{
6269
$this->resetApplicationWithConfig([
63-
'sentry.tracing.storage' => false,
70+
'filesystems.disks.local.driver' => 'sentry',
71+
'filesystems.disks.local.sentry_disk_name' => 'local',
72+
'filesystems.disks.local.sentry_enable_spans' => false,
73+
'filesystems.disks.local.sentry_original_driver' => 'local',
6474
]);
6575

6676
$hub = $this->getHubFromContainer();
@@ -77,6 +87,13 @@ public function testDoesntCreateSpansWhenDisabled(): void
7787

7888
public function testCreatesBreadcrumbsFor(): void
7989
{
90+
$this->resetApplicationWithConfig([
91+
'filesystems.disks.local.driver' => 'sentry',
92+
'filesystems.disks.local.sentry_disk_name' => 'local',
93+
'filesystems.disks.local.sentry_original_driver' => 'local',
94+
'filesystems.disks.local.sentry_enable_breadcrumbs' => true,
95+
]);
96+
8097
Storage::put('foo', 'bar');
8198
$fooContent = Storage::get('foo');
8299
Storage::assertExists('foo', 'bar');
@@ -120,7 +137,10 @@ public function testCreatesBreadcrumbsFor(): void
120137
public function testDoesntCreateBreadcrumbsWhenDisabled(): void
121138
{
122139
$this->resetApplicationWithConfig([
123-
'sentry.breadcrumbs.storage' => false,
140+
'filesystems.disks.local.driver' => 'sentry',
141+
'filesystems.disks.local.sentry_disk_name' => 'local',
142+
'filesystems.disks.local.sentry_original_driver' => 'local',
143+
'filesystems.disks.local.sentry_enable_breadcrumbs' => false,
124144
]);
125145

126146
Storage::exists('foo');

0 commit comments

Comments
 (0)