create(); if (Sdk::isDisabled()) { //@see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#general-sdk-configuration return $configurator->withPropagator($propagator); } $emitMetrics = Configuration::getBoolean(Variables::OTEL_PHP_INTERNAL_METRICS_ENABLED); $exporter = (new ExporterFactory())->create(); $meterProvider = (new MeterProviderFactory())->create(); $spanProcessor = (new SpanProcessorFactory())->create($exporter, $emitMetrics ? $meterProvider : null); $tracerProvider = (new TracerProviderBuilder()) ->addSpanProcessor($spanProcessor) ->setSampler((new SamplerFactory())->create()) ->build(); $loggerProvider = (new LoggerProviderFactory())->create($emitMetrics ? $meterProvider : null); ShutdownHandler::register([$tracerProvider, 'shutdown']); ShutdownHandler::register([$meterProvider, 'shutdown']); ShutdownHandler::register([$loggerProvider, 'shutdown']); return $configurator ->withTracerProvider($tracerProvider) ->withMeterProvider($meterProvider) ->withLoggerProvider($loggerProvider) ->withPropagator($propagator) ; }); return true; } /** * @internal */ public static function reset(): void { self::$enabled = null; } }