Skip to content

Commit 4b4cf7d

Browse files
committed
refactor: rename main_logger into framework_logger in bundle configuration
1 parent 29fe734 commit 4b4cf7d

8 files changed

Lines changed: 59 additions & 59 deletions

File tree

documentation/components/bridges/symfony-telemetry-bundle.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -674,23 +674,23 @@ In addition, the bundle always registers a `default` logger, meter, and tracer
674674

675675
**Options:**
676676

677-
| Option | Type | Default | Description |
678-
|---------------|------------------|---------|--------------------------------------------------------------------------------------------------------------|
679-
| `main_logger` | `string \| null` | `null` | Name of a logger configured under `loggers` (or the always-available `default`) to alias as Symfony `logger` |
677+
| Option | Type | Default | Description |
678+
|--------------------|------------------|---------|--------------------------------------------------------------------------------------------------------------|
679+
| `framework_logger` | `string \| null` | `null` | Name of a logger configured under `loggers` (or the always-available `default`) to alias as Symfony `logger` |
680680

681681
**Behavior:**
682682

683-
- When `main_logger` is set, the bundle aliases the Symfony `logger` service to `flow.telemetry.<main_logger>.logger.psr3`. If no logger with that name exists, container compilation fails with a clear error.
684-
- When `main_logger` is `null` and Symfony's `logger` service is the default `Symfony\Component\HttpKernel\Log\Logger`, the bundle automatically aliases `logger` to `flow.telemetry.default.logger.psr3`.
685-
- When `main_logger` is `null` and `logger` is provided by another bundle (Monolog, custom alias, etc.), the bundle leaves `logger` alone.
683+
- When `framework_logger` is set, the bundle aliases the Symfony `logger` service to `flow.telemetry.<framework_logger>.logger.psr3`. If no logger with that name exists, container compilation fails with a clear error.
684+
- When `framework_logger` is `null` and Symfony's `logger` service is the default `Symfony\Component\HttpKernel\Log\Logger`, the bundle automatically aliases `logger` to `flow.telemetry.default.logger.psr3`.
685+
- When `framework_logger` is `null` and `logger` is provided by another bundle (Monolog, custom alias, etc.), the bundle leaves `logger` alone.
686686

687687
```yaml
688688
flow_telemetry:
689689
loggers:
690690
app:
691691
version: '1.0.0'
692692
693-
main_logger: app # Symfony "logger" service -> flow.telemetry.app.logger.psr3
693+
framework_logger: app # Symfony "logger" service -> flow.telemetry.app.logger.psr3
694694
```
695695

696696
## Pattern Matching
@@ -887,7 +887,7 @@ flow_telemetry:
887887
checkout:
888888
version: '%env(APP_VERSION)%'
889889
890-
main_logger: app # Symfony "logger" service -> flow.telemetry.app.logger.psr3
890+
framework_logger: app # Symfony "logger" service -> flow.telemetry.app.logger.psr3
891891
892892
instrumentation:
893893
http_kernel:

src/bridge/psr3/telemetry/tests/Flow/Bridge/Psr3/Telemetry/Tests/Unit/SeverityMapperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Flow\Bridge\Psr3\Telemetry\Exception\InvalidArgumentException;
88
use Flow\Bridge\Psr3\Telemetry\SeverityMapper;
99
use Flow\Telemetry\Logger\Severity;
10-
use PHPUnit\Framework\Attributes\{DataProvider};
10+
use PHPUnit\Framework\Attributes\DataProvider;
1111
use PHPUnit\Framework\TestCase;
1212
use Psr\Log\LogLevel;
1313

src/bridge/psr3/telemetry/tests/Flow/Bridge/Psr3/Telemetry/Tests/Unit/TelemetryLoggerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Flow\Telemetry\Provider\Memory\MemoryLogProcessor;
1313
use Flow\Telemetry\Provider\Void\VoidLogExporter;
1414
use Flow\Telemetry\Resource;
15-
use PHPUnit\Framework\Attributes\{DataProvider};
15+
use PHPUnit\Framework\Attributes\DataProvider;
1616
use PHPUnit\Framework\TestCase;
1717
use Psr\Log\LogLevel;
1818

src/bridge/symfony/telemetry-bundle/src/Flow/Bridge/Symfony/TelemetryBundle/DependencyInjection/Compiler/MainLoggerPass.php renamed to src/bridge/symfony/telemetry-bundle/src/Flow/Bridge/Symfony/TelemetryBundle/DependencyInjection/Compiler/FrameworkLoggerPass.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@
88
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
99
use Symfony\Component\DependencyInjection\ContainerBuilder;
1010

11-
final class MainLoggerPass implements CompilerPassInterface
11+
final class FrameworkLoggerPass implements CompilerPassInterface
1212
{
1313
private const string SYMFONY_DEFAULT_LOGGER = 'Symfony\\Component\\HttpKernel\\Log\\Logger';
1414

1515
public function process(ContainerBuilder $container) : void
1616
{
17-
$mainLogger = $container->hasParameter('flow.telemetry.main_logger')
18-
? $container->getParameter('flow.telemetry.main_logger')
17+
$frameworkLogger = $container->hasParameter('flow.telemetry.framework_logger')
18+
? $container->getParameter('flow.telemetry.framework_logger')
1919
: null;
2020

21-
if ($mainLogger !== null) {
22-
if (!\is_string($mainLogger) || $mainLogger === '') {
23-
throw new RuntimeException('flow_telemetry.main_logger must be a non-empty string referencing a configured logger name.');
21+
if ($frameworkLogger !== null) {
22+
if (!\is_string($frameworkLogger) || $frameworkLogger === '') {
23+
throw new RuntimeException('flow_telemetry.framework_logger must be a non-empty string referencing a configured logger name.');
2424
}
2525

26-
$targetId = 'flow.telemetry.' . $mainLogger . '.logger.psr3';
26+
$targetId = 'flow.telemetry.' . $frameworkLogger . '.logger.psr3';
2727

2828
if (!$container->hasDefinition($targetId) && !$container->hasAlias($targetId)) {
2929
throw new RuntimeException(\sprintf(
30-
'Configured main_logger "%s" does not have a registered PSR-3 wrapper service "%s". Make sure a logger with that name is configured under flow_telemetry.loggers, or use the always-available "default".',
31-
$mainLogger,
30+
'Configured framework_logger "%s" does not have a registered PSR-3 wrapper service "%s". Make sure a logger with that name is configured under flow_telemetry.loggers, or use the always-available "default".',
31+
$frameworkLogger,
3232
$targetId,
3333
));
3434
}

src/bridge/symfony/telemetry-bundle/src/Flow/Bridge/Symfony/TelemetryBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function getConfigTreeBuilder() : TreeBuilder
111111
->info('Custom PSR-20 clock service ID. If not provided, uses built-in SystemClock.')
112112
->defaultNull()
113113
->end()
114-
->scalarNode('main_logger')
114+
->scalarNode('framework_logger')
115115
->info('Name of the logger (matching a key under "loggers", or "default") whose PSR-3 wrapper will be aliased to Symfony\'s "logger" service. Leave null to auto-replace only when Symfony\'s default HttpKernel Logger is currently bound.')
116116
->defaultNull()
117117
->end()

src/bridge/symfony/telemetry-bundle/src/Flow/Bridge/Symfony/TelemetryBundle/DependencyInjection/FlowTelemetryExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ public function load(array $configs, ContainerBuilder $container) : void
6767
{
6868
$loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
6969
$configuration = new Configuration();
70-
/** @var array{resource: array{detectors?: array{enabled?: bool, static?: array{cache?: array{enabled?: bool, path?: null|string}, os?: array{enabled?: bool}, host?: array{enabled?: bool}, service?: array{enabled?: bool}, deployment?: array{enabled?: bool}, environment?: array{enabled?: bool}}, dynamic?: array{process?: array{enabled?: bool}}}, custom?: array<string, mixed>}, clock_service_id?: null|string, main_logger?: null|string, context_storage?: array{type?: string, service_id?: null|string}, propagator?: array{type?: string, service_id?: null|string}, tracer_provider?: array<string, mixed>, meter_provider?: array<string, mixed>, logger_provider?: array<string, mixed>, instrumentation?: array{http_kernel?: array{enabled?: bool, exclude_paths?: array<array{path: string, method?: null|string}>, context_propagation?: bool}, console?: array{enabled?: bool, exclude_commands?: array<string>}, messenger?: array{enabled?: bool, context_propagation?: bool}, twig?: array{enabled?: bool, trace_templates?: bool, trace_blocks?: bool, trace_macros?: bool, exclude_templates?: array<string>}, http_client?: array{enabled?: bool, exclude_clients?: array<string>}, psr18_client?: array{enabled?: bool, exclude_clients?: array<string>}, dbal?: array{enabled?: bool, log_sql?: bool, max_sql_length?: int, exclude_connections?: array<string>}, cache?: array{enabled?: bool, exclude_pools?: array<string>}}, tracers?: array<string, array{version?: string, schema_url?: null|string, attributes?: array<string, mixed>}>, meters?: array<string, array{version?: string, schema_url?: null|string, attributes?: array<string, mixed>}>, loggers?: array<string, array{version?: string, schema_url?: null|string, attributes?: array<string, mixed>}>} $config */
70+
/** @var array{resource: array{detectors?: array{enabled?: bool, static?: array{cache?: array{enabled?: bool, path?: null|string}, os?: array{enabled?: bool}, host?: array{enabled?: bool}, service?: array{enabled?: bool}, deployment?: array{enabled?: bool}, environment?: array{enabled?: bool}}, dynamic?: array{process?: array{enabled?: bool}}}, custom?: array<string, mixed>}, clock_service_id?: null|string, framework_logger?: null|string, context_storage?: array{type?: string, service_id?: null|string}, propagator?: array{type?: string, service_id?: null|string}, tracer_provider?: array<string, mixed>, meter_provider?: array<string, mixed>, logger_provider?: array<string, mixed>, instrumentation?: array{http_kernel?: array{enabled?: bool, exclude_paths?: array<array{path: string, method?: null|string}>, context_propagation?: bool}, console?: array{enabled?: bool, exclude_commands?: array<string>}, messenger?: array{enabled?: bool, context_propagation?: bool}, twig?: array{enabled?: bool, trace_templates?: bool, trace_blocks?: bool, trace_macros?: bool, exclude_templates?: array<string>}, http_client?: array{enabled?: bool, exclude_clients?: array<string>}, psr18_client?: array{enabled?: bool, exclude_clients?: array<string>}, dbal?: array{enabled?: bool, log_sql?: bool, max_sql_length?: int, exclude_connections?: array<string>}, cache?: array{enabled?: bool, exclude_pools?: array<string>}}, tracers?: array<string, array{version?: string, schema_url?: null|string, attributes?: array<string, mixed>}>, meters?: array<string, array{version?: string, schema_url?: null|string, attributes?: array<string, mixed>}>, loggers?: array<string, array{version?: string, schema_url?: null|string, attributes?: array<string, mixed>}>} $config */
7171
$config = $this->processConfiguration($configuration, $configs);
7272

73-
$container->setParameter('flow.telemetry.main_logger', $config['main_logger'] ?? null);
73+
$container->setParameter('flow.telemetry.framework_logger', $config['framework_logger'] ?? null);
7474

7575
$tracers = ($config['tracers'] ?? []) + ['default' => []];
7676
$meters = ($config['meters'] ?? []) + ['default' => []];

src/bridge/symfony/telemetry-bundle/src/Flow/Bridge/Symfony/TelemetryBundle/FlowTelemetryBundle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Flow\Bridge\Symfony\TelemetryBundle;
66

7-
use Flow\Bridge\Symfony\TelemetryBundle\DependencyInjection\Compiler\{CacheTelemetryPass, DBALTelemetryPass, HttpClientTelemetryPass, MainLoggerPass, OTLPAvailabilityPass, Psr18ClientTelemetryPass};
7+
use Flow\Bridge\Symfony\TelemetryBundle\DependencyInjection\Compiler\{CacheTelemetryPass, DBALTelemetryPass, FrameworkLoggerPass, HttpClientTelemetryPass, OTLPAvailabilityPass, Psr18ClientTelemetryPass};
88
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
99
use Symfony\Component\DependencyInjection\ContainerBuilder;
1010
use Symfony\Component\HttpKernel\Bundle\Bundle;
@@ -26,7 +26,7 @@ public function build(ContainerBuilder $container) : void
2626
parent::build($container);
2727

2828
$container->addCompilerPass(new OTLPAvailabilityPass());
29-
$container->addCompilerPass(new MainLoggerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -64);
29+
$container->addCompilerPass(new FrameworkLoggerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -64);
3030

3131
if (\interface_exists(self::HTTP_CLIENT_INTERFACE)) {
3232
$container->addCompilerPass(new HttpClientTelemetryPass());

src/bridge/symfony/telemetry-bundle/tests/Flow/Bridge/Symfony/TelemetryBundle/Tests/Integration/FlowTelemetryExtensionTest.php

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Flow\Bridge\Symfony\TelemetryBundle\Tests\Integration;
66

77
use Flow\Bridge\Psr3\Telemetry\TelemetryLogger;
8-
use Flow\Bridge\Symfony\TelemetryBundle\DependencyInjection\Compiler\{MainLoggerPass, OTLPAvailabilityPass};
8+
use Flow\Bridge\Symfony\TelemetryBundle\DependencyInjection\Compiler\{FrameworkLoggerPass, OTLPAvailabilityPass};
99
use Flow\Bridge\Symfony\TelemetryBundle\DependencyInjection\FlowTelemetryExtension;
1010
use Flow\Bridge\Symfony\TelemetryBundle\Exception\RuntimeException;
1111
use Flow\Bridge\Symfony\TelemetryBundle\Tests\Fixtures\Logger\StubLogger;
@@ -30,7 +30,7 @@
3030

3131
#[CoversClass(FlowTelemetryExtension::class)]
3232
#[CoversClass(OTLPAvailabilityPass::class)]
33-
#[CoversClass(MainLoggerPass::class)]
33+
#[CoversClass(FrameworkLoggerPass::class)]
3434
final class FlowTelemetryExtensionTest extends KernelTestCase
3535
{
3636
public function test_auto_alias_when_logger_service_is_symfony_default() : void
@@ -316,6 +316,39 @@ public function test_flow_telemetry_is_aliased_to_telemetry_class() : void
316316
self::assertSame($container->get('flow.telemetry'), $container->get(Telemetry::class));
317317
}
318318

319+
public function test_framework_logger_aliases_symfony_logger_service_to_psr3_wrapper() : void
320+
{
321+
$this->bootKernel([
322+
'config' => static function (TestKernel $kernel) : void {
323+
$kernel->addTestExtensionConfig('flow_telemetry', [
324+
'resource' => [],
325+
'loggers' => ['app' => []],
326+
'framework_logger' => 'app',
327+
]);
328+
},
329+
]);
330+
331+
$container = $this->getContainer();
332+
333+
self::assertTrue($container->has('logger'));
334+
self::assertInstanceOf(TelemetryLogger::class, $container->get('logger'));
335+
}
336+
337+
public function test_framework_logger_throws_when_referenced_logger_is_not_configured() : void
338+
{
339+
self::expectException(RuntimeException::class);
340+
self::expectExceptionMessage('flow.telemetry.missing.logger.psr3');
341+
342+
$this->bootKernel([
343+
'config' => static function (TestKernel $kernel) : void {
344+
$kernel->addTestExtensionConfig('flow_telemetry', [
345+
'resource' => [],
346+
'framework_logger' => 'missing',
347+
]);
348+
},
349+
]);
350+
}
351+
319352
public function test_full_configuration_scenario() : void
320353
{
321354
$this->bootKernel([
@@ -478,39 +511,6 @@ public function test_log_processor_void_type() : void
478511
self::assertInstanceOf(VoidLogProcessor::class, $this->getContainer()->get('flow.telemetry.logger_provider.processor'));
479512
}
480513

481-
public function test_main_logger_aliases_symfony_logger_service_to_psr3_wrapper() : void
482-
{
483-
$this->bootKernel([
484-
'config' => static function (TestKernel $kernel) : void {
485-
$kernel->addTestExtensionConfig('flow_telemetry', [
486-
'resource' => [],
487-
'loggers' => ['app' => []],
488-
'main_logger' => 'app',
489-
]);
490-
},
491-
]);
492-
493-
$container = $this->getContainer();
494-
495-
self::assertTrue($container->has('logger'));
496-
self::assertInstanceOf(TelemetryLogger::class, $container->get('logger'));
497-
}
498-
499-
public function test_main_logger_throws_when_referenced_logger_is_not_configured() : void
500-
{
501-
self::expectException(RuntimeException::class);
502-
self::expectExceptionMessage('flow.telemetry.missing.logger.psr3');
503-
504-
$this->bootKernel([
505-
'config' => static function (TestKernel $kernel) : void {
506-
$kernel->addTestExtensionConfig('flow_telemetry', [
507-
'resource' => [],
508-
'main_logger' => 'missing',
509-
]);
510-
},
511-
]);
512-
}
513-
514514
public function test_metric_exporter_console_type() : void
515515
{
516516
$this->bootKernel([

0 commit comments

Comments
 (0)