fix observing namespaced functions#200
Merged
brettmc merged 4 commits intoopen-telemetry:mainfrom Oct 2, 2025
Merged
Conversation
if a user wants to observe a namespaced function, this allows adding the observer with or without a leading slash. Previously, the leading slash caused the lookup to fail, which is not clear to users. Added a test to show that it works with both forms now.
Nevay
reviewed
Sep 29, 2025
ext/otel_observer.c
Outdated
| static bool find_observers(HashTable *ht, zend_string *n, zend_llist *pre_hooks, | ||
| zend_llist *post_hooks) { | ||
| otel_observer *observer = zend_hash_find_ptr_lc(ht, n); | ||
| zend_string *normalized = normalize_fq_func_name(n); |
Contributor
There was a problem hiding this comment.
Should instead strip the leading \ in add_function_observer to avoid the allocations during lookup.
per review feedback
Nevay
approved these changes
Oct 1, 2025
| @@ -0,0 +1,74 @@ | |||
| --TEST-- | |||
| Check hooking namespaced function | |||
Contributor
There was a problem hiding this comment.
Might also want to add a test for hooking a namespaced class method with leading \ in the classname.
ChrisLightfootWild
approved these changes
Oct 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
if a user wants to observe a namespaced function, this allows adding the observer with or without a leading slash. Previously, the leading slash caused the lookup to fail, which is not clear to users. Added a test to show that it works with both forms now.
Fixes: open-telemetry/opentelemetry-php#1720