To extend the configuration model, implement the ComponentProvider interface. A provider must implement two methods:
getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinition: Defines the configuration schema for the component using an ArrayNodeDefinition. This allows you to specify required fields, default values, and constraints (like min()). You can also reference other components in the registry (e.g., an exporter) using $registry->component(...).createPlugin(array $properties, Context $context): T: Uses the parsed $properties array to instantiate and return the actual component (e.g., a SpanProcessor).
final class SpanProcessorBatch implements ComponentProvider {
/**
* @param array{
* schedule_delay: int<0, max>,
* export_timeout: int<0, max>,
* max_queue_size: int<0, max>,
* max_export_batch_size: int<0, max>,
* exporter: ComponentPlugin<SpanExporter>,
* } $properties
*/
public function createPlugin(array $properties, Context $context): SpanProcessor {
// ...
}
public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinition {
$node = new ArrayNodeDefinition('batch');
$node
->children()
->integerNode('schedule_delay')->min(0)->defaultValue(5000)->end()
->integerNode('export_timeout')->min(0)->defaultValue(30000)->end()
->integerNode('max_queue_size')->min(0)->defaultValue(2048)->end()
->integerNode('max_export_batch_size')->min(0)->defaultValue(512)->end()
->append($registry->component('exporter', SpanExporter::class)->isRequired())
->end()
;
return $node;
}
}