Skip to content

[opentelemetry-php-contrib] Pre hook exception Symfony\Component\HttpKernel\Controller\ErrorController could not be converted to string #1569

Open
open-telemetry/opentelemetry-php-contrib
#366
@trigrab

Description

@trigrab

Describe your environment

I am running a symfony 6.4 app with opentelemetry-auto-symfony installed. In some subrequests I get this Warning in my nginx error logs:

*41 FastCGI sent in stderr: "PHP message: PHP Warning:  Symfony\Component\HttpKernel\HttpKernel::handle(): OpenTelemetry: pre hook threw exception, class=Symfony\Component\HttpKernel\HttpKernel function=handle message=Object of class Symfony\Component\HttpKernel\Controller\ErrorController could not be converted to string in Unknown on line 0" while reading response header from upstream, client: 172.110.1.1, server: someserver $, request: "GET someWrongUrl

To me it seems like either the symfony instrumentation for HttpKernel handle should not expect the _controller attribute, which in my case is the HttpKernel ErrorController, to be a string SymfonyInstrumentation.php#L50 or the ErrorController of the HttpKernel component should implment a __toString() function. I am not a php developer and I have no experience in symfony development. Therefor I don't know the right behavior for this. But I expect the exception should not be thrown.

Steps to reproduce
I expect any symfony app (6.4 or above) would have the same error when HttpKernel ErrorController is part of a subrequest. The assumption that _controller is a string is the problem here.
As I am not a php developer I cannot tell how to reproduce in a minimal setup and I cannot share my symfony app.
If necessary I will ask a collegue who is php developer to provide a minimal setup.

What is the expected behavior?
There should be no exception. My error should be handled by the ErrorController.

What is the actual behavior?
Warning about an exception in the opentelemetry symfony pre hook for HttpKernel handle

Additional context
I don't think it is connected, but I am running a container based symfony app in version 6.8 with php 8.4.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions