open-telemetry / detector-container
OpenTelemetry container resource detector
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
This is a read-only subtree split of https://github.com/open-telemetry/opentelemetry-php-contrib.
OpenTelemetry Container Detector
This package provides an OpenTelemetry ResourceDetector
which will detect docker container id at runtime, using either V1 (cgroup) or V2 (mountinfo).
It should work with docker, kubernetes, and podman containers.
Requirements
- OpenTelemetry SDK
Installation via composer
$ composer require open-telemetry/detector-container
Usage
The detector will be automatically registered as part of composer autoloading.
By default, all built-in and registered custom resource detectors are used, and will be added to the default resources associated with traces, metrics, and logs.
You can also provide a list of detectors via the OTEL_PHP_DETECTORS
config (environment variable or php.ini setting):
putenv('OTEL_PHP_DETECTORS=container,env,os,<others>') var_dump(ResourceInfoFactory::defaultResource());