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

Breadcrumb

  1. Drupal Core 11.1.x

TracerSharedState.php

Namespace

OpenTelemetry\SDK\Trace

File

vendor/open-telemetry/sdk/Trace/TracerSharedState.php

View source
<?php

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

use OpenTelemetry\API\Trace as API;

/** @phan-suppress-current-line PhanUnreferencedUseNormal */
use OpenTelemetry\SDK\Common\Future\CancellationInterface;
use OpenTelemetry\SDK\Resource\ResourceInfo;
use OpenTelemetry\SDK\Trace\SpanProcessor\MultiSpanProcessor;
use OpenTelemetry\SDK\Trace\SpanProcessor\NoopSpanProcessor;

/**
 * Stores shared state/config between all {@see API\TracerInterface} created via the same {@see API\TracerProviderInterface}.
 */
final class TracerSharedState {
    private readonly SpanProcessorInterface $spanProcessor;
    private ?bool $shutdownResult = null;
    public function __construct(IdGeneratorInterface $idGenerator, ResourceInfo $resource, SpanLimits $spanLimits, SamplerInterface $sampler, array $spanProcessors) {
        $this->spanProcessor = match (count($spanProcessors)) {    0 => NoopSpanProcessor::getInstance(),
            1 => $spanProcessors[0],
            default => new MultiSpanProcessor(...$spanProcessors),
        
        };
    }
    public function hasShutdown() : bool {
        return null !== $this->shutdownResult;
    }
    public function getIdGenerator() : IdGeneratorInterface {
        return $this->idGenerator;
    }
    public function getResource() : ResourceInfo {
        return $this->resource;
    }
    public function getSpanLimits() : SpanLimits {
        return $this->spanLimits;
    }
    public function getSampler() : SamplerInterface {
        return $this->sampler;
    }
    public function getSpanProcessor() : SpanProcessorInterface {
        return $this->spanProcessor;
    }
    
    /**
     * Returns `false` is the provider is already shutdown, otherwise `true`.
     */
    public function shutdown(?CancellationInterface $cancellation = null) : bool {
        return $this->shutdownResult ?? ($this->shutdownResult = $this->spanProcessor
            ->shutdown($cancellation));
    }

}

Classes

Title Deprecated Summary
TracerSharedState Stores shared state/config between all {

API Navigation

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