Skip to content

Commit

Permalink
fix: Replace object key by Predis Connection
Browse files Browse the repository at this point in the history
  • Loading branch information
PROFeNoM committed Feb 4, 2025
1 parent af9ad1e commit d28b8c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/DDTrace/Integrations/Predis/PredisIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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;
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Integrations/Predis/Latest/PredisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down

0 comments on commit d28b8c4

Please sign in to comment.