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

Breadcrumb

  1. Drupal Core 11.1.x
  2. Sdk.php

class Sdk

Same name in this branch
  1. 11.1.x vendor/open-telemetry/sdk/Sdk.php \OpenTelemetry\SDK\Sdk

Hierarchy

  • class \OpenTelemetry\SDK\Resource\Detectors\Sdk implements \OpenTelemetry\SDK\Resource\ResourceDetectorInterface

Expanded class hierarchy of Sdk

See also

https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8…

1 file declares its use of Sdk
OtlpUtil.php in vendor/open-telemetry/exporter-otlp/OtlpUtil.php

File

vendor/open-telemetry/sdk/Resource/Detectors/Sdk.php, line 17

Namespace

OpenTelemetry\SDK\Resource\Detectors
View source
final class Sdk implements ResourceDetectorInterface {
    private const PACKAGES = [
        'open-telemetry/sdk',
        'open-telemetry/opentelemetry',
    ];
    public function getResource() : ResourceInfo {
        $attributes = [
            ResourceAttributes::TELEMETRY_SDK_NAME => 'opentelemetry',
            ResourceAttributes::TELEMETRY_SDK_LANGUAGE => 'php',
        ];
        if (class_exists(InstalledVersions::class)) {
            foreach (self::PACKAGES as $package) {
                if (!InstalledVersions::isInstalled($package)) {
                    continue;
                }
                if (($version = InstalledVersions::getPrettyVersion($package)) === null) {
                    continue;
                }
                $attributes[ResourceAttributes::TELEMETRY_SDK_VERSION] = $version;
                break;
            }
        }
        if (extension_loaded('opentelemetry')) {
            $attributes[ResourceAttributes::TELEMETRY_DISTRO_NAME] = 'opentelemetry-php-instrumentation';
            $attributes[ResourceAttributes::TELEMETRY_DISTRO_VERSION] = phpversion('opentelemetry');
        }
        return ResourceInfo::create(Attributes::create($attributes), ResourceAttributes::SCHEMA_URL);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
Sdk::getResource public function Overrides ResourceDetectorInterface::getResource
Sdk::PACKAGES private constant

API Navigation

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