Make OpenTelemetry work with FiberBoundContextStorage

Created on 18 November 2024, 3 days ago

Problem/Motivation

The "open-telemetry/context" library started to use the FiberBoundContextStorage by default, which relies on the function Fiber::getCurrent().

But Drupal started to use the function Fiber::getCurrent() too, in the Renderer and BigPipe.

That leads to conflicts because Drupal Kernel calls the Fiber::getCurrent()->suspend() which puts the OpenTelemetry FiberBoundContextStorage service on suspend.

The temporary workaround is to force set the simple OpenTelemetry\Context\ContextStorage() on the initialization stage:

function OpentelemetryTraceManager::__construct() {
...
    // Force disable the FiberBoundContextStorage because of the conflict
    // with Drupal Renderer service.
    // @todo Make a proper fix to work well with the FiberBoundContextStorage.
    $contextStorage = new ContextStorage();
    Context::setStorage($contextStorage);
...

We need to investigate this and find a fix on the Drupal or OpenTelemetry side.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇦🇲Armenia murz Yerevan, Armenia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @murz
  • 🇫🇷France andypost

    It may work if core patched to pass context into fiber but ++ to find out general approach without hacking every place where Fiber is created

    AUto-instrumentation using FFI+ZTS also overkill

Production build 0.71.5 2024