Skip to content

Commit

Permalink
Merge pull request #98 from AgencyPMG/empty_recieve
Browse files Browse the repository at this point in the history
Change Span Names When No Message is Handled
  • Loading branch information
chrisguitarguy authored Jul 23, 2024
2 parents 7fa8fd9 + 09c28b7 commit e121aaa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Otel/PmgQueueInstrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public static function register(): bool
$span->setStatus(StatusCode::STATUS_ERROR, $exception->getMessage());
} elseif ($result === false) {
$span->setStatus(StatusCode::STATUS_ERROR, 'Message was not handled successfully');
} elseif ($result === null) {
$span->updateName($queueName.' empty-receive');
}

$span->end();
Expand Down
2 changes: 1 addition & 1 deletion test/integration/ConsumerOtelIntTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testConsumerOnceEmitsSpansWhenNoMessagesAreHandled() : void
$this->assertFalse($called);
$this->assertCount(1, $this->spans);
$span = $this->spans[0];
$this->assertSame(self::Q.' receive', $span->getName());
$this->assertSame(self::Q.' empty-receive', $span->getName());
$attr = $span->getAttributes();
$this->assertSame(self::Q, $attr->get(TraceAttributes::MESSAGING_DESTINATION_NAME));
$this->assertSame('receive', $attr->get(PmgQueueInstrumentation::OPERATION_TYPE));
Expand Down

0 comments on commit e121aaa

Please sign in to comment.