Skip to content

Commit 374e393

Browse files
committed
Merge branch 'telescope_filtering' of https://github.com/paras-malhotra/docs into paras-malhotra-telescope_filtering
2 parents 1741969 + ebb2b85 commit 374e393

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

telescope.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
- [Configuration](#configuration)
66
- [Data Pruning](#data-pruning)
77
- [Dashboard Authorization](#dashboard-authorization)
8+
- [Filtering](#filtering)
9+
- [Entries](#filtering-entries)
10+
- [Batches](#filtering-batches)
811

912
<a name="introduction"></a>
1013
## Introduction
@@ -98,3 +101,60 @@ Telescope exposes a dashboard at `/telescope`. By default, you will only be able
98101
]);
99102
});
100103
}
104+
105+
<a name="filtering"></a>
106+
## Filtering
107+
108+
<a name="filtering-entries"></a>
109+
### Entries
110+
111+
Telescope allows you to record filtered entries by registering a callback via the `filter` method in your `app/Providers/TelescopeServiceProvider.php` file:
112+
113+
/**
114+
* Register any application services.
115+
*
116+
* @return void
117+
*/
118+
public function register()
119+
{
120+
$this->hideSensitiveRequestDetails();
121+
122+
Telescope::filter(function (IncomingEntry $entry) {
123+
if ($this->app->isLocal()) {
124+
return true;
125+
}
126+
127+
return $entry->isReportableException() ||
128+
$entry->isFailedJob() ||
129+
$entry->isScheduledTask() ||
130+
$entry->hasMonitoredTag();
131+
});
132+
}
133+
134+
<a name="filtering-batches"></a>
135+
### Batches
136+
137+
Besides filtering at the entry level, you may also filter batches (request or console application cycles) while retaining all the entries associated with the filtered batches by using the `filterBatch` method:
138+
139+
/**
140+
* Register any application services.
141+
*
142+
* @return void
143+
*/
144+
public function register()
145+
{
146+
$this->hideSensitiveRequestDetails();
147+
148+
Telescope::filterBatch(function ($entries) {
149+
if ($this->app->isLocal()) {
150+
return true;
151+
}
152+
153+
return $entries->contains(function ($entry) {
154+
return $entry->isReportableException() ||
155+
$entry->isFailedJob() ||
156+
$entry->isScheduledTask() ||
157+
$entry->hasMonitoredTag();
158+
});
159+
});
160+
}

0 commit comments

Comments
 (0)