Skip to content

Commit

Permalink
Add TransactionContext::make() & SpanContext::make() (#1684)
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric authored Jan 18, 2024
1 parent 1cc36e6 commit 62274fb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/Tracing/SpanContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ class SpanContext
*/
private $endTimestamp;

/**
* @return self
*/
public static function make()
{
return new self();
}

public function getDescription(): ?string
{
return $this->description;
Expand Down
8 changes: 8 additions & 0 deletions src/Tracing/TransactionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public function __construct(
$this->metadata = $metadata ?? new TransactionMetadata();
}

/**
* @return self
*/
public static function make()
{
return new self();
}

/**
* Gets the name of the transaction.
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/Tracing/SpanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testStartChild(): void
->setSpanId(SpanId::generate())
->setTraceId(TraceId::generate());

$spanContext2 = (new SpanContext())
$spanContext2 = SpanContext::make()
->setSampled(true)
->setParentSpanId($spanContext2ParentSpanId)
->setTraceId($spanContext2TraceId);
Expand Down
2 changes: 1 addition & 1 deletion tests/Tracing/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testFinish(): void
ClockMock::withClockMock(1600640877);

$expectedEventId = null;
$transactionContext = (new TransactionContext())
$transactionContext = TransactionContext::make()
->setTags(['ios_version' => '4.0'])
->setSampled(true)
->setStartTimestamp(1600640865);
Expand Down

0 comments on commit 62274fb

Please sign in to comment.