From 48e575db47c5a301cac084f5eeb5cae13883a44a Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Thu, 18 Dec 2025 14:05:27 +0100 Subject: [PATCH] ref: add high level `flush` to flush all resources --- src/SentrySdk.php | 18 ++++++++++++++++++ src/functions.php | 15 +++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/SentrySdk.php b/src/SentrySdk.php index 4b41fc30a..7621b44a6 100644 --- a/src/SentrySdk.php +++ b/src/SentrySdk.php @@ -4,6 +4,8 @@ namespace Sentry; +use Sentry\Logs\Logs; +use Sentry\Metrics\TraceMetrics; use Sentry\State\Hub; use Sentry\State\HubInterface; @@ -61,4 +63,20 @@ public static function setCurrentHub(HubInterface $hub): HubInterface return $hub; } + + /** + * Flushes all buffered telemetry data. + * + * This is a convenience facade that forwards the flush operation to all + * internally managed components. + * + * Calling this method is equivalent to invoking `flush()` on each component + * individually. It does not change flushing behavior, improve performance, + * or reduce the number of network requests. + */ + public static function flush(): void + { + Logs::getInstance()->flush(); + TraceMetrics::getInstance()->flush(); + } } diff --git a/src/functions.php b/src/functions.php index af967c8f9..2ff257151 100644 --- a/src/functions.php +++ b/src/functions.php @@ -396,3 +396,18 @@ function addFeatureFlag(string $name, bool $result): void $scope->addFeatureFlag($name, $result); }); } + +/** + * Flushes all buffered telemetry data. + * + * This is a convenience facade that forwards the flush operation to all + * internally managed components. + * + * Calling this method is equivalent to invoking `flush()` on each component + * individually. It does not change flushing behavior, improve performance, + * or reduce the number of network requests. + */ +function flush(): void +{ + SentrySdk::flush(); +}