Skip to content

log_export_enabled: true fails with "non-existent service OtelLogHandler" #17

Description

@srekcud

Enabling log_export_enabled: true in v1.6.0 causes a container compilation error:

The service "monolog.logger" has a dependency on a non-existent service
"Traceway\OpenTelemetryBundle\Monolog\OtelLogHandler".

Steps to reproduce

  1. Install traceway/opentelemetry-symfony v1.6.0
  2. Add to config/packages/open_telemetry.yaml:
    open_telemetry:
        log_export_enabled: true                                                                                                                                                             
        log_export_level: info                                                                                                                                                               
  3. Run php bin/console cache:clear --env=prod

Root cause

prepend() injects a monolog handler config referencing OtelLogHandler::class as a service, but the service definition is registered in load().

Symfony calls load() in bundle registration order. When MonologBundle is registered before OpenTelemetryBundle (the default), MonologBundle's load() runs first and creates a
Reference(OtelLogHandler::class) from the prepended config — but the service doesn't exist yet because OpenTelemetryBundle's load() hasn't run.

CheckExceptionOnInvalidReferenceBehaviorPass then fails on the unresolved reference.

Environment

  • PHP 8.5, Symfony 8.0
  • traceway/opentelemetry-symfony v1.6.0
  • symfony/monolog-bundle 4.0.2

PS : PR incoming

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions