diff --git a/src/SDK/Resource/ResourceInfoFactory.php b/src/SDK/Resource/ResourceInfoFactory.php index 7fc80bcd9..507d967de 100644 --- a/src/SDK/Resource/ResourceInfoFactory.php +++ b/src/SDK/Resource/ResourceInfoFactory.php @@ -17,6 +17,8 @@ class ResourceInfoFactory { use LogsMessagesTrait; + private static ?ResourceInfo $emptyResource = null; + public static function defaultResource(): ResourceInfo { $detectors = Configuration::getList(Env::OTEL_PHP_DETECTORS); @@ -90,6 +92,10 @@ public static function defaultResource(): ResourceInfo public static function emptyResource(): ResourceInfo { - return ResourceInfo::create(Attributes::create([])); + if (null === self::$emptyResource) { + self::$emptyResource = ResourceInfo::create(Attributes::create([])); + } + + return self::$emptyResource; } }