Skip to content

Commit

Permalink
Change Span Names When No Message is Handled
Browse files Browse the repository at this point in the history
With the idea being to make these spans easier to drop.
  • Loading branch information
chrisguitarguy committed Jul 23, 2024
1 parent 7fa8fd9 commit 09c28b7
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 09c28b7

Please sign in to comment.