- Issue created by @pix_
- Merge request !67Issue #3532182: remove opentelemetry dependency injection from DatabaseStatementTraceEventSubscriber → (Open) created by Unnamed author
When the opentelemetry module is installed and the "Database Statement" trace plugin is enabled, clearing the Drupal cache from UI results in a fatal error:
Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "Drupal\opentelemetry\EventSubscriber\DatabaseStatementTraceEventSubscriber"
This occurs because the DatabaseStatementTraceEventSubscriber
has a direct dependency on the opentelemetry service. During service container compilation, instantiating this subscriber triggers a dependency chain that eventually requires the config.factory service, which in turn depends on the event_dispatcher. Since the event_dispatcher needs all subscribers to be instantiated first, this creates a circular reference that breaks site builds and cache clears.
ServiceCircularReferenceException
fatal error.The website encountered an unexpected error. Try again later.
Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "Drupal\opentelemetry\EventSubscriber\DatabaseStatementTraceEventSubscriber", path: "Drupal\opentelemetry\EventSubscriber\DatabaseStatementTraceEventSubscriber -> opentelemetry -> opentelemetry.tracer_provider -> opentelemetry.span_processor -> opentelemetry.span.exporter -> opentelemetry.span.exporter.factory -> opentelemetry.traces.transport.factory -> opentelemetry.transport.factory.provider". in Drupal\Component\DependencyInjection\Container->get() (line 147 of core/lib/Drupal/Component/DependencyInjection/Container.php).
Drupal\Component\DependencyInjection\Container->get() (Line: 454)
Drupal\Component\DependencyInjection\Container->Drupal\Component\DependencyInjection\{closure}() (Line: 185)
Drupal\tracer\EventDispatcher\TraceableEventDispatcher->addCalledListener() (Line: 158)
Drupal\tracer\EventDispatcher\TraceableEventDispatcher->callListeners() (Line: 77)
Drupal\tracer\EventDispatcher\TraceableEventDispatcher->dispatch() (Line: 1527)
Drupal\Core\Database\Connection->dispatchEvent() (Line: 135)
...
Drupal\Core\DrupalKernel->handle() (Line: 19)
The circular dependency will be resolved by removing the direct service injection of opentelemetry from the DatabaseStatementTraceEventSubscriber
's constructor and dynamically retrieving the opentelemetry service within its event methods, but only if the service has already been initialized by the container. Same as
https://www.drupal.org/project/opentelemetry/issues/3392836
📌
Make a soft dependency for the ExceptionTraceEventSubscriber
Fixed
Active
1.0
Code