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

Breadcrumb

  1. Drupal Core 11.1.x

Span.php

Same filename in this branch
  1. 11.1.x vendor/open-telemetry/sdk/Trace/Span.php
  2. 11.1.x vendor/open-telemetry/gen-otlp-protobuf/Opentelemetry/Proto/Trace/V1/Span.php

Namespace

OpenTelemetry\API\Trace

File

vendor/open-telemetry/api/Trace/Span.php

View source
<?php

declare (strict_types=1);
namespace OpenTelemetry\API\Trace;

use OpenTelemetry\Context\Context;
use OpenTelemetry\Context\ContextInterface;
use OpenTelemetry\Context\ContextKeys;
use OpenTelemetry\Context\ScopeInterface;
abstract class Span implements SpanInterface {
    private static ?self $invalidSpan = null;
    
    /** @inheritDoc */
    public static final function fromContext(ContextInterface $context) : SpanInterface {
        return $context->get(ContextKeys::span()) ?? self::getInvalid();
    }
    
    /** @inheritDoc */
    public static final function getCurrent() : SpanInterface {
        return self::fromContext(Context::getCurrent());
    }
    
    /** @inheritDoc */
    public static final function getInvalid() : SpanInterface {
        if (null === self::$invalidSpan) {
            self::$invalidSpan = new NonRecordingSpan(SpanContext::getInvalid());
        }
        return self::$invalidSpan;
    }
    
    /** @inheritDoc */
    public static final function wrap(SpanContextInterface $spanContext) : SpanInterface {
        if (!$spanContext->isValid()) {
            return self::getInvalid();
        }
        return new NonRecordingSpan($spanContext);
    }
    
    /** @inheritDoc */
    public final function activate() : ScopeInterface {
        return Context::getCurrent()->withContextValue($this)
            ->activate();
    }
    
    /** @inheritDoc */
    public final function storeInContext(ContextInterface $context) : ContextInterface {
        if (LocalRootSpan::isLocalRoot($context)) {
            $context = LocalRootSpan::store($context, $this);
        }
        return $context->with(ContextKeys::span(), $this);
    }

}

Classes

Title Deprecated Summary
Span

API Navigation

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