Skip to content

[Bug] Installing opentelemetry bundle breaks existing Monolog config #193

@ToshY

Description

@ToshY

Problem

After installing friendsofopentelemetry/opentelemetry-bundle, I've created the config like stated in the docs, and then wanted to dump the reference config with config:dump-reference open_telemetry (like stated in the configuration section).

I have an existing monolog.yaml like this.

monolog:
  channels:
    - deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
  handlers:
    deprecation:
      type: "null"
      channels: [ deprecation ]

when@dev:
  monolog:
    handlers:
      main:
        type: stream
        path: "%kernel.logs_dir%/%kernel.environment%.log"
        level: debug
        channels: [ "!event" ]
      # uncomment to get logging in your browser
      # you may have to allow bigger header sizes in your Web server configuration
      #firephp:
      #    type: firephp
      #    level: info
      #chromephp:
      #    type: chromephp
      #    level: info
      console:
        type: console
        process_psr_3_messages: false
        channels: [ "!event", "!doctrine", "!console" ]

when@test:
  monolog:
    handlers:
      main:
        type: fingers_crossed
        action_level: error
        handler: nested
        excluded_http_codes: [ 404, 405 ]
        channels: [ "!event" ]
      nested:
        type: stream
        path: "%kernel.logs_dir%/%kernel.environment%.log"
        level: debug

when@prod:
  monolog:
    handlers:
      main:
        type: fingers_crossed
        action_level: error
        handler: nested
        excluded_http_codes: [ 404, 405 ]
        buffer_size: 50 # How many messages should be saved? Prevent memory leaks
      nested:
        type: stream
        path: php://stderr
        level: debug
        formatter: monolog.formatter.json
      console:
        type: console
        process_psr_3_messages: false
        channels: [ "!event", "!doctrine" ]
      deprecation:
        type: stream
        channels: [ deprecation ]
        path: php://stderr

When on APP_ENV=dev, I've executed config:dump-reference open_telemetry -vvv and it gives an error now.

Monolog configuration error: The logging channel "deprecation" assigned to the "deprecation" handler does not exist

Verbose output

task app:console -- config:dump-reference open_telemetry -vvv
task: [app:console] docker compose exec $TTY phpfpm bin/console config:dump-reference open_telemetry -vvv

In LoggerChannelPass.php line 104:

  [InvalidArgumentException]
  Monolog configuration error: The logging channel "deprecation" assigned to the "deprecation" handler does not exist.


Exception trace:
  at /app/vendor/symfony/monolog-bundle/DependencyInjection/Compiler/LoggerChannelPass.php:104
 Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass->process() at /app/vendor/symfony/dependency-injection/Compiler/Compiler.php:73
 Symfony\Component\DependencyInjection\Compiler\Compiler->compile() at /app/vendor/symfony/dependency-injection/ContainerBuilder.php:814
 Symfony\Component\DependencyInjection\ContainerBuilder->compile() at /app/vendor/symfony/http-kernel/Kernel.php:499
 Symfony\Component\HttpKernel\Kernel->initializeContainer() at /app/vendor/symfony/http-kernel/Kernel.php:744
 Symfony\Component\HttpKernel\Kernel->preBoot() at /app/vendor/symfony/http-kernel/Kernel.php:120
 Symfony\Component\HttpKernel\Kernel->boot() at /app/vendor/symfony/framework-bundle/Console/Application.php:177
 Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() at /app/vendor/symfony/framework-bundle/Console/Application.php:69
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /app/vendor/symfony/console/Application.php:192
 Symfony\Component\Console\Application->run() at /app/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /app/vendor/autoload_runtime.php:29
 require_once() at /app/bin/console:11

In ContainerBuilder.php line 1042:

  [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
  You have requested a non-existent service "monolog.logger.deprecation".


Exception trace:
  at /app/vendor/symfony/dependency-injection/ContainerBuilder.php:1042
 Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition() at /app/vendor/symfony/monolog-bundle/DependencyInjection/Compiler/LoggerChannelPass.php:101
 Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass->process() at /app/vendor/symfony/dependency-injection/Compiler/Compiler.php:73
 Symfony\Component\DependencyInjection\Compiler\Compiler->compile() at /app/vendor/symfony/dependency-injection/ContainerBuilder.php:814
 Symfony\Component\DependencyInjection\ContainerBuilder->compile() at /app/vendor/symfony/http-kernel/Kernel.php:499
 Symfony\Component\HttpKernel\Kernel->initializeContainer() at /app/vendor/symfony/http-kernel/Kernel.php:744
 Symfony\Component\HttpKernel\Kernel->preBoot() at /app/vendor/symfony/http-kernel/Kernel.php:120
 Symfony\Component\HttpKernel\Kernel->boot() at /app/vendor/symfony/framework-bundle/Console/Application.php:177
 Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() at /app/vendor/symfony/framework-bundle/Console/Application.php:69
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /app/vendor/symfony/console/Application.php:192
 Symfony\Component\Console\Application->run() at /app/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /app/vendor/autoload_runtime.php:29
 require_once() at /app/bin/console:11

task: Failed to run task "app:console": exit status 1

This problem does not occur without friendsofopentelemetry/opentelemetry-bundle

Library Version
friendsofopentelemetry/opentelemetry-bundle v1.0.0-beta.5
symfony/monolog-bundle v3.10.0
monolog/monolog 3.9.0
symfony 7.3.*

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions