Skip to content

Commit e597efe

Browse files
committed
Corona: Add method to get tags specific to the current span
1 parent 2b87d8f commit e597efe

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/Lunr/Corona/Request.php

+17
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use BackedEnum;
1414
use Lunr\Corona\Parsers\TracingInfo\TracingInfoValue;
15+
use Lunr\Ticks\EventLogging\EventInterface;
1516
use Lunr\Ticks\TracingControllerInterface;
1617
use Lunr\Ticks\TracingInfoInterface;
1718
use RuntimeException;
@@ -21,6 +22,8 @@
2122
* Manages access to $_POST, $_GET values, as well as
2223
* the request URL parameters
2324
*
25+
* @phpstan-import-type Tags from EventInterface
26+
*
2427
* @property-read string $action The HTTP method used for the request
2528
* @property-read string $protocol The protocol used for the request
2629
* @property-read string $domain The domain used for the request
@@ -203,6 +206,20 @@ public function getParentSpanId(): ?string
203206
return $this->get(TracingInfoValue::ParentSpanID);
204207
}
205208

209+
/**
210+
* Get tags that are specific to the current span.
211+
*
212+
* @return Tags Indexed metadata about the current span
213+
*/
214+
public function getSpanSpecificTags(): array
215+
{
216+
return [
217+
'controller' => $this->controller,
218+
'method' => $this->method,
219+
'call' => $this->call,
220+
];
221+
}
222+
206223
/**
207224
* Get a request value.
208225
*

src/Lunr/Corona/Tests/RequestGetValueTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,24 @@ public function testGetParentSpanIdWithUncachedValue(): void
321321
$this->assertEquals($id, $value);
322322
}
323323

324+
/**
325+
* Test getSpanSpecificTags().
326+
*
327+
* @covers Lunr\Corona\Request::getSpanSpecificTags
328+
*/
329+
public function testGetSpanSpecificTags()
330+
{
331+
$expected = [
332+
'controller' => 'controller',
333+
'method' => 'method',
334+
'call' => 'controller/method',
335+
];
336+
337+
$value = $this->class->getSpanSpecificTags();
338+
339+
$this->assertEquals($expected, $value);
340+
}
341+
324342
}
325343

326344
?>

0 commit comments

Comments
 (0)