diff --git a/src/Tracing/Transaction.php b/src/Tracing/Transaction.php index 4c832d369..ba72c2e80 100644 --- a/src/Tracing/Transaction.php +++ b/src/Tracing/Transaction.php @@ -70,10 +70,14 @@ public function getName(): string * Sets the name of this transaction. * * @param string $name The name + * + * @return $this */ - public function setName(string $name): void + public function setName(string $name): self { $this->name = $name; + + return $this; } /** diff --git a/tests/Tracing/TransactionTest.php b/tests/Tracing/TransactionTest.php index 576a689f8..262559c4b 100644 --- a/tests/Tracing/TransactionTest.php +++ b/tests/Tracing/TransactionTest.php @@ -86,6 +86,18 @@ public function testFinishDoesNothingIfSampledFlagIsNotTrue(): void $transaction->finish(); } + public function testFluentApi(): void + { + $transaction = new Transaction(TransactionContext::make()); + $tags = ['foo' => 'bar']; + $name = 'baz'; + $transaction->setTags($tags) + ->setName($name) + ->finish(); + $this->assertSame($tags, $transaction->getTags()); + $this->assertSame($name, $transaction->getName()); + } + /** * @dataProvider parentTransactionContextDataProvider */