← All changes
|
vendor_prefixed/sentry/sentry/src/functions.php
+34
-3
1.10.15
→
1.10.21
View file →
| @@ -3,8 +3,9 @@ | ||
| 3 | 3 | declare (strict_types=1); |
| 4 | 4 | namespace WCPOS\Vendor\Sentry; |
| 5 | 5 | |
| 6 | 6 | use WCPOS\Vendor\Psr\Log\LoggerInterface; |
| 7 | +use WCPOS\Vendor\Sentry\Attachment\Attachment; | |
| 7 | 8 | use WCPOS\Vendor\Sentry\HttpClient\HttpClientInterface; |
| 8 | 9 | use WCPOS\Vendor\Sentry\Integration\IntegrationInterface; |
| 9 | 10 | use WCPOS\Vendor\Sentry\Integration\OTLPIntegration; |
| 10 | 11 | use WCPOS\Vendor\Sentry\Logs\Logs; |
| @@ -9,8 +10,9 @@ | ||
| 9 | 10 | use WCPOS\Vendor\Sentry\Integration\OTLPIntegration; |
| 10 | 11 | use WCPOS\Vendor\Sentry\Logs\Logs; |
| 11 | 12 | use WCPOS\Vendor\Sentry\Metrics\Metrics; |
| 12 | 13 | use WCPOS\Vendor\Sentry\Metrics\TraceMetrics; |
| 14 | +use WCPOS\Vendor\Sentry\State\HubInterface; | |
| 13 | 15 | use WCPOS\Vendor\Sentry\State\Scope; |
| 14 | 16 | use WCPOS\Vendor\Sentry\Tracing\PropagationContext; |
| 15 | 17 | use WCPOS\Vendor\Sentry\Tracing\SpanContext; |
| 16 | 18 | use WCPOS\Vendor\Sentry\Tracing\Transaction; |
| @@ -200,12 +202,31 @@ | ||
| 200 | 202 | function withScope(callable $callback) |
| 201 | 203 | { |
| 202 | 204 | return SentrySdk::getCurrentHub()->withScope($callback); |
| 203 | 205 | } |
| 204 | -function startContext() : void | |
| 206 | +/** | |
| 207 | + * Starts an isolated context for the current logical execution. | |
| 208 | + * | |
| 209 | + * A provided hub is used as-is, allowing runtimes with their own HubInterface | |
| 210 | + * implementation to manage hub isolation. When no hub is provided, the SDK | |
| 211 | + * creates an isolated hub from the baseline. | |
| 212 | + * | |
| 213 | + * If a context is already active, this function is a no-op and the provided hub | |
| 214 | + * is ignored. Use SentrySdk::setCurrentHub() to replace the active context's hub. | |
| 215 | + * | |
| 216 | + * @param HubInterface|null $hub The hub to use for the new context | |
| 217 | + */ | |
| 218 | +function startContext(?HubInterface $hub = null) : void | |
| 205 | 219 | { |
| 206 | - SentrySdk::startContext(); | |
| 220 | + SentrySdk::startContext($hub); | |
| 207 | 221 | } |
| 222 | +/** | |
| 223 | + * Ends and flushes the active context for the current logical execution. | |
| 224 | + * | |
| 225 | + * When no context is active this is a no-op. | |
| 226 | + * | |
| 227 | + * @param int|null $timeout The maximum number of seconds to wait while flushing the client transport | |
| 228 | + */ | |
| 208 | 229 | function endContext(?int $timeout = null) : void |
| 209 | 230 | { |
| 210 | 231 | SentrySdk::endContext($timeout); |
| 211 | 232 | } |
| @@ -211,9 +232,9 @@ | ||
| 211 | 232 | } |
| 212 | 233 | /** |
| 213 | 234 | * Executes the given callback within an isolated context. |
| 214 | 235 | * |
| 215 | - * If a context is already active for the current execution key, it is reused. | |
| 236 | + * If a context is already active for the current logical execution, it is reused. | |
| 216 | 237 | * |
| 217 | 238 | * @param callable $callback The callback to execute |
| 218 | 239 | * @param int|null $timeout The maximum number of seconds to wait while flushing the client transport |
| 219 | 240 | * |
| @@ -434,8 +455,18 @@ | ||
| 434 | 455 | function addFeatureFlag(string $name, bool $result) : void |
| 435 | 456 | { |
| 436 | 457 | SentrySdk::getCurrentHub()->configureScope(static function (Scope $scope) use($name, $result) { |
| 437 | 458 | $scope->addFeatureFlag($name, $result); |
| 459 | + }); | |
| 460 | +} | |
| 461 | +/** | |
| 462 | + * Adds an attachment to the current scope. For large attachments, it might be helpful | |
| 463 | + * to use the SDK Sidecar Transport: https://docs.sentry.io/platforms/php/agent/. | |
| 464 | + */ | |
| 465 | +function addAttachment(Attachment $attachment) : void | |
| 466 | +{ | |
| 467 | + SentrySdk::getCurrentHub()->configureScope(static function (Scope $scope) use($attachment) { | |
| 468 | + $scope->addAttachment($attachment); | |
| 438 | 469 | }); |
| 439 | 470 | } |
| 440 | 471 | /** |
| 441 | 472 | * Flushes all buffered telemetry data. |