functions.php
Same filename in this branch
- 11.1.x vendor/ramsey/uuid/src/functions.php
- 11.1.x vendor/open-telemetry/sdk/Common/Util/functions.php
- 11.1.x vendor/phpunit/phpunit/src/Framework/Assert/Functions.php
- 11.1.x vendor/react/promise/src/functions.php
- 11.1.x vendor/guzzlehttp/guzzle/src/functions.php
- 11.1.x vendor/symfony/string/Resources/functions.php
Namespace
OpenTelemetry\API\TraceFile
-
vendor/
open-telemetry/ api/ Trace/ functions.php
View source
<?php
declare (strict_types=1);
namespace OpenTelemetry\API\Trace;
use Closure;
use Throwable;
/**
* Executes the given closure within the provided span.
*
* The span will be ended.
*
* @template R
* @param SpanInterface $span span to enclose the closure with
* @param Closure(...): R $closure closure to invoke
* @param iterable<int|string, mixed> $args arguments to provide to the closure
* @return R result of the closure invocation
*
* @phpstan-ignore-next-line
*/
function trace(SpanInterface $span, Closure $closure, iterable $args = []) {
$s = $span;
$c = $closure;
$a = $args;
unset($span, $closure, $args);
$scope = $s->activate();
try {
/** @psalm-suppress InvalidArgument */
return $c(...$a, ...$a = []);
} catch (Throwable $e) {
$s->setStatus(StatusCode::STATUS_ERROR, $e->getMessage());
$s->recordException($e, [
'exception.escaped' => true,
]);
throw $e;
} finally {
$scope->detach();
$s->end();
}
}
Functions
Title | Deprecated | Summary |
---|---|---|
trace | Executes the given closure within the provided span. |