Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. WithSpanHandler.php

function WithSpanHandler::post

File

vendor/open-telemetry/api/Instrumentation/WithSpanHandler.php, line 49

Class

WithSpanHandler
Generic pre-hook and post-hook handlers for attribute-based auto instrumentation

Namespace

OpenTelemetry\API\Instrumentation

Code

public static function post(mixed $target, array $params, mixed $result, ?Throwable $exception) : void {
    $scope = Context::storage()->scope();
    $scope?->detach();
    if (!$scope || $scope->context() === Context::getCurrent()) {
        return;
    }
    $span = Span::fromContext($scope->context());
    if ($exception) {
        $span->recordException($exception, [
            'exception.escaped' => true,
        ]);
        $span->setStatus(StatusCode::STATUS_ERROR, $exception->getMessage());
    }
    $span->end();
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal