Skip to content

[opentelemetry-php-instrumentation] Can't seem to hook namespaced functions. #1720

@bartvanhoutte

Description

@bartvanhoutte

Describe your environment
PHP 8.4

opentelemetry.allow_stack_extension
Off
opentelemetry.attr_hooks_enabled
Off
opentelemetry.attr_post_handler_function
OpenTelemetry\API\Instrumentation\WithSpanHandler::post
opentelemetry.attr_pre_handler_function
OpenTelemetry\API\Instrumentation\WithSpanHandler::pre
opentelemetry.conflicts

opentelemetry.display_warnings
Off
opentelemetry.validate_hook_functions
On

Steps to reproduce
Create a hook for a namespaced function:

        hook(
            class: null,
            function: '\Some\Namespace\hookMe',
            pre: function (...$args) {
                print_r($args);
                return $args;
            },
        );

What is the expected behavior?
A printout of the arguments passed to \Some\Namespace\hookMe.

What is the actual behavior?
Nothing happens

Additional context
This works for functions that are not in a namespace.

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

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