@@ -79,6 +79,13 @@ class EventHandler
7979 */
8080 private $ traceQueueJobsAsTransactions ;
8181
82+ /**
83+ * Indicates if we should trace HTTP client requests.
84+ *
85+ * @var bool
86+ */
87+ private $ traceHttpClientRequests ;
88+
8289 /**
8390 * Hold the stack of parent spans that need to be put back on the scope.
8491 *
@@ -108,6 +115,8 @@ public function __construct(array $config, BacktraceHelper $backtraceHelper)
108115 $ this ->traceSqlQueries = ($ config ['sql_queries ' ] ?? true ) === true ;
109116 $ this ->traceSqlQueryOrigins = ($ config ['sql_origin ' ] ?? true ) === true ;
110117
118+ $ this ->traceHttpClientRequests = ($ config ['http_client_requests ' ] ?? true ) === true ;
119+
111120 $ this ->traceQueueJobs = ($ config ['queue_jobs ' ] ?? false ) === true ;
112121 $ this ->traceQueueJobsAsTransactions = ($ config ['queue_job_transactions ' ] ?? false ) === true ;
113122
@@ -283,6 +292,10 @@ protected function transactionRolledBackHandler(DatabaseEvents\TransactionRolled
283292
284293 protected function httpClientRequestSendingHandler (HttpClientEvents \RequestSending $ event ): void
285294 {
295+ if (!$ this ->traceHttpClientRequests ) {
296+ return ;
297+ }
298+
286299 $ parentSpan = SentrySdk::getCurrentHub ()->getSpan ();
287300
288301 // If there is no tracing span active there is no need to handle the event
@@ -300,6 +313,10 @@ protected function httpClientRequestSendingHandler(HttpClientEvents\RequestSendi
300313
301314 protected function httpClientResponseReceivedHandler (HttpClientEvents \ResponseReceived $ event ): void
302315 {
316+ if (!$ this ->traceHttpClientRequests ) {
317+ return ;
318+ }
319+
303320 $ span = $ this ->popSpan ();
304321
305322 if ($ span !== null ) {
@@ -310,6 +327,10 @@ protected function httpClientResponseReceivedHandler(HttpClientEvents\ResponseRe
310327
311328 protected function httpClientConnectionFailedHandler (HttpClientEvents \ConnectionFailed $ event ): void
312329 {
330+ if (!$ this ->traceHttpClientRequests ) {
331+ return ;
332+ }
333+
313334 $ span = $ this ->popSpan ();
314335
315336 if ($ span !== null ) {
0 commit comments