Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelreyrol committed Jan 20, 2025
1 parent 424e551 commit eee9bf8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Trace\TracerProvider\TraceProviderEnum;
use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Trace\TraceSamplerEnum;
use Monolog\Level;
use OpenTelemetry\API\Common\Time\SystemClock;
use OpenTelemetry\SDK\Logs\Processor\BatchLogRecordProcessor;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
Expand Down Expand Up @@ -500,8 +502,19 @@ private function getLogsProcessorsNode(): ArrayNodeDefinition
->scalarPrototype()
->end()
->end()
->arrayNode('batch')
->info('Required if processor type is batch')
->children()
->scalarNode('clock')->defaultValue(SystemClock::class)->end()
->integerNode('max_queue_size')->isRequired()->defaultValue(BatchLogRecordProcessor::DEFAULT_MAX_QUEUE_SIZE)->end()
->integerNode('schedule_delay')->isRequired()->defaultValue(BatchLogRecordProcessor::DEFAULT_SCHEDULE_DELAY)->end()
->integerNode('export_timeout')->isRequired()->defaultValue(BatchLogRecordProcessor::DEFAULT_EXPORT_TIMEOUT)->end()
->integerNode('max_export_batch_size')->isRequired()->defaultValue(BatchLogRecordProcessor::DEFAULT_MAX_EXPORT_BATCH_SIZE)->end()
->scalarNode('provider')->isRequired()->end()
->end()
->end()
->scalarNode('exporter')
->info('Required if processor type is simple')
->info('Required if processor type is simple or batch')
->cannotBeEmpty()
->end()
->end()
Expand Down
16 changes: 16 additions & 0 deletions src/OpenTelemetry/Log/LogProcessor/BatchLogProcessorFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Log\LogProcessor;

use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Log\LogProcessor\LogProcessorFactoryInterface;
use OpenTelemetry\SDK\Logs\LogRecordExporterInterface;
use OpenTelemetry\SDK\Logs\LogRecordProcessorInterface;
use OpenTelemetry\SDK\Logs\Processor\BatchLogRecordProcessor;

final class BatchLogProcessorFactory implements LogProcessorFactoryInterface
{
public function createProcessor(array $processors = [], ?LogRecordExporterInterface $exporter = null): LogRecordProcessorInterface
{
return new BatchLogRecordProcessor();

Check failure on line 14 in src/OpenTelemetry/Log/LogProcessor/BatchLogProcessorFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (PHP 8.3)

Class OpenTelemetry\SDK\Logs\Processor\BatchLogRecordProcessor constructor invoked with 0 parameters, 2-8 required.
}
}
1 change: 1 addition & 0 deletions src/OpenTelemetry/Log/LogProcessor/LogProcessorEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

enum LogProcessorEnum: string
{
case Batch = 'batch';
case Multi = 'multi';
case Noop = 'noop';
case Simple = 'simple';
Expand Down
4 changes: 4 additions & 0 deletions src/Resources/config/services_logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Log\LoggerProvider\DefaultLoggerProviderFactory;
use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Log\LoggerProvider\NoopLoggerProviderFactory;
use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Log\LogProcessor\AbstractLogProcessorFactory;
use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Log\LogProcessor\BatchLogProcessorFactory;
use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Log\LogProcessor\MultiLogProcessorFactory;
use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Log\LogProcessor\NoopLogProcessorFactory;
use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Log\LogProcessor\SimpleLogProcessorFactory;
Expand Down Expand Up @@ -71,6 +72,9 @@
])
->tag('monolog.logger', ['channel' => 'open_telemetry'])

->set('open_telemetry.logs.processor_factory.batch', BatchLogProcessorFactory::class)
->parent('open_telemetry.logs.processor_factory.abstract')

->set('open_telemetry.logs.processor_factory.multi', MultiLogProcessorFactory::class)
->parent('open_telemetry.logs.processor_factory.abstract')

Expand Down

0 comments on commit eee9bf8

Please sign in to comment.