Skip to content

Commit

Permalink
Allow fluent use of Transaction::setName() method (#1687)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfb authored Jan 22, 2024
1 parent 29d00b0 commit 617dde3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Tracing/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/Tracing/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 617dde3

Please sign in to comment.