| Conditions | 1 |
| Paths | 1 |
| Total Lines | 28 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 1 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | 2 | public function trace( |
|
| 22 | string $name, |
||
| 23 | callable $callback, |
||
| 24 | array $attributes = [], |
||
| 25 | bool $scoped = false, |
||
| 26 | bool $debug = false, |
||
| 27 | ?TraceKind $traceKind = null, |
||
| 28 | ?int $startTime = null |
||
| 29 | ): mixed { |
||
| 30 | 2 | $span = new Span($name); |
|
| 31 | |||
| 32 | 2 | $startTime ??= $this->clock->now(); |
|
| 33 | |||
| 34 | 2 | $result = $this->scope->runScope([ |
|
| 35 | SpanInterface::class => $span, |
||
| 36 | 2 | ], static fn (InvokerInterface $invoker): mixed => $invoker->invoke($callback)); |
|
| 37 | |||
| 38 | 2 | $elapsed = $this->clock->now() - $startTime; |
|
| 39 | |||
| 40 | 2 | $this->logger->debug(\sprintf('Trace [%s] - [%01.4f ms.]', $name, $elapsed / 1_000_000_000), [ |
|
|
|
|||
| 41 | 2 | 'attributes' => $span->getAttributes(), |
|
| 42 | 2 | 'status' => $span->getStatus(), |
|
| 43 | 'scoped' => $scoped, |
||
| 44 | 'trace_kind' => $traceKind, |
||
| 45 | 'elapsed' => $elapsed, |
||
| 46 | ]); |
||
| 47 | |||
| 48 | 2 | return $result; |
|
| 49 | } |
||
| 56 |