Closed dhempel closed 8 months ago
@dhempel - what's your intent for using SpanContextKey before initialization? Curious as to how you found this.
@bobstrecansky Hi, I don't want to modify the initialization. I'm also surprised and thought it might be a PHP 8.2 relevant issue when autoloading the package open-telemetry/context, as there the script fiber/initialize_fiber_handler.php is running, which executes the function Context::setStorage which leads to this error.
@bobstrecansky: Hi again, maybe it is caused by my unit tests which use @backupStaticAttributes enabled in this case.
@bobstrecansky Otherwise i can't reproduce this issue within a simple cli script.
Context::$spanContextKey
is initialized on Context
construction during the first call to Context::getRoot()
(which is also called by Context::getCurrent()
); the static property is only accessed in instance methods -> it should not be possible to be uninitialized under normal circumstances. Context::setStorage()
should not access the context at all.
Which version of PHPUnit and sebastian/global-state
are you using / can you provide a PHPUnit setup that reproduces this issue? Normally @backupStaticAttributes
should skip uninitialized properties.
We are still using an old version of Phpunit, which is probably related to the error:
name : phpunit/phpunit
versions : * 8.5.36
....
sebastian/global-state ^3.0.0
I will provide a setup asap to reproduce this.
Hello everyone, I can't easily reproduce it and I don't have the time to provide the simple example.
Describe your environment
Steps to reproduce Autoloading for open-telemetry/context will throw the error above, which I converted into a stack trace
What is the expected behavior? No error and working unittest with standard boostrapping
What is the actual behavior? Typed static property OpenTelemetry\Context\Context::$spanContextKey must not be accessed before initialization
Additional context Suggestion:
modified initialization of property: