From d28b8c453884306590e2c5622b13ec22cb7f3e2f Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 4 Feb 2025 09:06:18 +0100 Subject: [PATCH] fix: Replace object key by Predis Connection --- src/DDTrace/Integrations/Predis/PredisIntegration.php | 10 +++++----- tests/Integrations/Predis/Latest/PredisTest.php | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/DDTrace/Integrations/Predis/PredisIntegration.php b/src/DDTrace/Integrations/Predis/PredisIntegration.php index a0b8f5579b2..acf0aa94f89 100644 --- a/src/DDTrace/Integrations/Predis/PredisIntegration.php +++ b/src/DDTrace/Integrations/Predis/PredisIntegration.php @@ -105,7 +105,7 @@ public function init(): int $span->name = 'Predis.Pipeline.executePipeline'; $span->resource = $span->name; $span->type = Type::REDIS; - PredisIntegration::setMetaAndServiceFromConnection($this, $span); + PredisIntegration::setMetaAndServiceFromConnection($this->getClient(), $span); if (\count($args) < 2) { return; } @@ -161,8 +161,8 @@ public static function storeConnectionMetaAndService($predis, $args) } } - ObjectKVStore::put($predis, 'service', $service); - ObjectKVStore::put($predis, 'connection_meta', $tags); + ObjectKVStore::put($predis->getConnection(), 'service', $service); + ObjectKVStore::put($predis->getConnection(), 'connection_meta', $tags); } /** @@ -175,12 +175,12 @@ public static function storeConnectionMetaAndService($predis, $args) */ public static function setMetaAndServiceFromConnection($predis, SpanData $span) { - $span->service = ObjectKVStore::get($predis, 'service', PredisIntegration::DEFAULT_SERVICE_NAME); + $span->service = ObjectKVStore::get($predis->getConnection(), 'service', PredisIntegration::DEFAULT_SERVICE_NAME); $span->meta[Tag::SPAN_KIND] = 'client'; $span->meta[Tag::COMPONENT] = PredisIntegration::NAME; $span->meta[Tag::DB_SYSTEM] = PredisIntegration::SYSTEM; - foreach (ObjectKVStore::get($predis, 'connection_meta', []) as $tag => $value) { + foreach (ObjectKVStore::get($predis->getConnection(), 'connection_meta', []) as $tag => $value) { $span->meta[$tag] = $value; } } diff --git a/tests/Integrations/Predis/Latest/PredisTest.php b/tests/Integrations/Predis/Latest/PredisTest.php index 5863201d3b5..d6349dd6b3f 100644 --- a/tests/Integrations/Predis/Latest/PredisTest.php +++ b/tests/Integrations/Predis/Latest/PredisTest.php @@ -251,6 +251,8 @@ public function testPredisPipeline() Tag::COMPONENT => 'predis', Tag::DB_SYSTEM => 'redis', 'redis.pipeline_length' => '2', + Tag::TARGET_HOST => $this->host, + Tag::TARGET_PORT => $this->port, ]; $this->assertFlameGraph($traces, [