ChainDetector implements ResourceDetector
Read onlyYes
FinalYes
Combines multiple resource detectors into a chain.
Detectors are executed in order and their results are merged. Later detectors take precedence over earlier ones when there are conflicting attribute keys (allowing for override patterns).
This is useful for combining automatic detection with manual overrides:
$detector = new ChainDetector(
new OsDetector(), // Base OS detection
new HostDetector(), // Host information
new ProcessDetector(), // Process information
new ComposerDetector(), // Service from composer
new EnvironmentDetector(), // Environment overrides (highest precedence)
);
The recommended order is:
- Infrastructure detectors (OS, Host)
- Runtime detectors (Process)
- Application detectors (Composer)
- Environment overrides (EnvironmentDetector - should be last)
Interfaces
- ResourceDetector
- Interface for detecting resource attributes from the environment.
Methods
- __construct() : mixed
- detect() : Resource
- Detect resource attributes from the environment.
Methods
__construct()
public
__construct(ResourceDetector ...$detectors) : mixed
Parameters
- $detectors : ResourceDetector
detect()
Detect resource attributes from the environment.
public
detect() : Resource