Skip to content

Commit 617dde3

Browse files
authored
Allow fluent use of Transaction::setName() method (#1687)
1 parent 29d00b0 commit 617dde3

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Tracing/Transaction.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ public function getName(): string
7070
* Sets the name of this transaction.
7171
*
7272
* @param string $name The name
73+
*
74+
* @return $this
7375
*/
74-
public function setName(string $name): void
76+
public function setName(string $name): self
7577
{
7678
$this->name = $name;
79+
80+
return $this;
7781
}
7882

7983
/**

tests/Tracing/TransactionTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ public function testFinishDoesNothingIfSampledFlagIsNotTrue(): void
8686
$transaction->finish();
8787
}
8888

89+
public function testFluentApi(): void
90+
{
91+
$transaction = new Transaction(TransactionContext::make());
92+
$tags = ['foo' => 'bar'];
93+
$name = 'baz';
94+
$transaction->setTags($tags)
95+
->setName($name)
96+
->finish();
97+
$this->assertSame($tags, $transaction->getTags());
98+
$this->assertSame($name, $transaction->getName());
99+
}
100+
89101
/**
90102
* @dataProvider parentTransactionContextDataProvider
91103
*/

0 commit comments

Comments
 (0)