PHP code example of tbachert / otel-sdk-configuration
1. Go to this page and download the library: Download tbachert/otel-sdk-configuration library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tbachert / otel-sdk-configuration example snippets
$factory = new ConfigurationFactory(
[
// all available providers ...
],
new OpenTelemetryConfiguration(),
new EnvSourceReader([
new ArrayEnvSource($_SERVER),
new PhpIniEnvSource(),
]),
);
$configuration = $factory->parseFile(__DIR__ . '/config.yaml');
$openTelemetry = $configuration->create(new Context());
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;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.