Skip to content

Commit 48e575d

Browse files
committed
ref: add high level flush to flush all resources
1 parent 15ac54b commit 48e575d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/SentrySdk.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Sentry;
66

7+
use Sentry\Logs\Logs;
8+
use Sentry\Metrics\TraceMetrics;
79
use Sentry\State\Hub;
810
use Sentry\State\HubInterface;
911

@@ -61,4 +63,20 @@ public static function setCurrentHub(HubInterface $hub): HubInterface
6163

6264
return $hub;
6365
}
66+
67+
/**
68+
* Flushes all buffered telemetry data.
69+
*
70+
* This is a convenience facade that forwards the flush operation to all
71+
* internally managed components.
72+
*
73+
* Calling this method is equivalent to invoking `flush()` on each component
74+
* individually. It does not change flushing behavior, improve performance,
75+
* or reduce the number of network requests.
76+
*/
77+
public static function flush(): void
78+
{
79+
Logs::getInstance()->flush();
80+
TraceMetrics::getInstance()->flush();
81+
}
6482
}

src/functions.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,3 +396,18 @@ function addFeatureFlag(string $name, bool $result): void
396396
$scope->addFeatureFlag($name, $result);
397397
});
398398
}
399+
400+
/**
401+
* Flushes all buffered telemetry data.
402+
*
403+
* This is a convenience facade that forwards the flush operation to all
404+
* internally managed components.
405+
*
406+
* Calling this method is equivalent to invoking `flush()` on each component
407+
* individually. It does not change flushing behavior, improve performance,
408+
* or reduce the number of network requests.
409+
*/
410+
function flush(): void
411+
{
412+
SentrySdk::flush();
413+
}

0 commit comments

Comments
 (0)