open-telemetry / detector-container
OpenTelemetry 容器资源检测器
1.0.0
2023-10-11 22:27 UTC
Requires
- php: ^7.0|^8.0
- open-telemetry/sdk: >= 1.0.0RC1 <= 2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- guzzlehttp/promises: ^1.5
- mikey179/vfsstream: ^1.6.11
- nyholm/psr7: ^1.5
- phan/phan: ^5.0
- php-http/message-factory: ^1.0
- phpstan/phpstan: ^1.1
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.16
- symfony/http-client: ^5.4|^6.0
- vimeo/psalm: ^4.0
README
这是 https://github.com/open-telemetry/opentelemetry-php-contrib 的只读子树分割。
OpenTelemetry 容器检测器
此包提供了一个 OpenTelemetry ResourceDetector
,该检测器将在运行时检测 docker 容器 ID,使用 V1(cgroup)或 V2(mountinfo)。它应该与 docker、kubernetes 和 podman 容器一起工作。
要求
- OpenTelemetry SDK
通过 composer 安装
$ composer require open-telemetry/detector-container
使用方法
检测器将自动注册为 composer 自动加载的一部分。
默认情况下,所有内置和已注册的自定义资源检测器都会使用,并将添加到与跟踪、指标和日志关联的默认资源。
您还可以通过 OTEL_PHP_DETECTORS
配置(环境变量或 php.ini 设置)提供一个检测器列表。
putenv('OTEL_PHP_DETECTORS=container,env,os,<others>') var_dump(ResourceInfoFactory::defaultResource());