Skip to content

Commit

Permalink
fix(elasticsearch): Hook not being removed (#2616)
Browse files Browse the repository at this point in the history
* fix: Hook not being removed

* style: Remove unused import
  • Loading branch information
PROFeNoM authored Apr 5, 2024
1 parent 0d08bf6 commit f244736
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DDTrace\Integrations\ElasticSearch\V8;

use DDTrace\HookData;
use DDTrace\Integrations\ElasticSearch\V1\ElasticSearchCommon;
use DDTrace\Integrations\Integration;
use DDTrace\SpanData;
Expand Down Expand Up @@ -33,14 +34,16 @@ public function init()
"posthook" => function (SpanData $span) use (&$constructorCalled, $integration) {
if (!$constructorCalled) {
foreach (get_class_methods('Elastic\Elasticsearch\Traits\NamespaceTrait') as $method) {
$hook = function ($obj, $scope, $args, $ret) use ($integration, $method) {
\dd_untrace('Elastic\Elasticsearch\Traits\NamespaceTrait', $method);
$hook = function (HookData $hook) use ($integration, $method) {
$ret = $hook->returned;
\DDTrace\remove_hook($hook->id);
$class = get_class($ret);
foreach (get_class_methods($ret) as $method) {
$integration->traceNamespaceMethod($class, $method);
}
};
\DDTrace\hook_method('Elastic\Elasticsearch\Client', $method, null, $hook);

\DDTrace\install_hook("Elastic\Elasticsearch\Client::$method", null, $hook);
}
foreach (get_class_methods('Elastic\Elasticsearch\Traits\ClientEndpointsTrait') as $method) {
$analyticsMethods = [
Expand Down

0 comments on commit f244736

Please sign in to comment.