open-telemetry/detector-container

OpenTelemetry container resource detector

1.0.0 2023-10-11 22:27 UTC

This package is auto-updated.

Last update: 2024-10-19 00:00:55 UTC


README

Releases Issues Source Mirror Latest Version Stable

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());