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

Breadcrumb

  1. Drupal Core 11.1.x

PropagatorFactory.php

Namespace

OpenTelemetry\SDK\Propagation

File

vendor/open-telemetry/sdk/Propagation/PropagatorFactory.php

View source
<?php

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

use OpenTelemetry\API\Behavior\LogsMessagesTrait;
use OpenTelemetry\Context\Propagation\MultiTextMapPropagator;
use OpenTelemetry\Context\Propagation\NoopTextMapPropagator;
use OpenTelemetry\Context\Propagation\TextMapPropagatorInterface;
use OpenTelemetry\SDK\Common\Configuration\Configuration;
use OpenTelemetry\SDK\Common\Configuration\Variables;
use OpenTelemetry\SDK\Registry;
class PropagatorFactory {
    use LogsMessagesTrait;
    public function create() : TextMapPropagatorInterface {
        $propagators = Configuration::getList(Variables::OTEL_PROPAGATORS);
        return match (count($propagators)) {    0 => new NoopTextMapPropagator(),
            1 => $this->buildPropagator($propagators[0]),
            default => new MultiTextMapPropagator($this->buildPropagators($propagators)),
        
        };
    }
    
    /**
     * @return list<TextMapPropagatorInterface>
     */
    private function buildPropagators(array $names) : array {
        $propagators = [];
        foreach ($names as $name) {
            $propagators[] = $this->buildPropagator($name);
        }
        return $propagators;
    }
    private function buildPropagator(string $name) : TextMapPropagatorInterface {
        try {
            return Registry::textMapPropagator($name);
        } catch (\RuntimeException $e) {
            self::logWarning($e->getMessage());
        }
        return NoopTextMapPropagator::getInstance();
    }

}

Classes

Title Deprecated Summary
PropagatorFactory

API Navigation

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