Skip to content

Commit

Permalink
improved types
Browse files Browse the repository at this point in the history
  • Loading branch information
cappuc committed Feb 9, 2024
1 parent e4c2d09 commit 837197d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 7
level: 8
paths:
- src
- config
Expand Down
2 changes: 1 addition & 1 deletion src/Support/SpanBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function startSpan(): SpanInterface
* @template U
*
* @param Closure(SpanInterface $span): U $callback
* @return U
* @return (U is PendingDispatch ? null : U)
*
* @throws Throwable
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Tracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Keepsuit\LaravelOpenTelemetry;

use Closure;
use Illuminate\Foundation\Bus\PendingDispatch;
use Illuminate\Support\Facades\Log;
use Keepsuit\LaravelOpenTelemetry\Support\SpanBuilder;
use OpenTelemetry\API\Trace\SpanInterface;
Expand Down Expand Up @@ -42,7 +43,7 @@ public function start(string $name): SpanInterface
*
* @param non-empty-string $name
* @param Closure(SpanInterface $span): U $callback
* @return U
* @return (U is PendingDispatch ? null : U)
*
* @throws \Throwable
*/
Expand Down
3 changes: 2 additions & 1 deletion tests/Instrumentation/QueueInstrumentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Illuminate\Support\Facades\Artisan;
use Keepsuit\LaravelOpenTelemetry\Facades\Tracer;
use Keepsuit\LaravelOpenTelemetry\Tests\Support\TestJob;
use OpenTelemetry\API\Trace\SpanInterface;
use OpenTelemetry\API\Trace\SpanKind;
use OpenTelemetry\SDK\Trace\Span;
use Spatie\Valuestore\Valuestore;
Expand All @@ -21,7 +22,7 @@

Tracer::newSpan('dispatcher')
->setSpanKind(SpanKind::KIND_PRODUCER)
->measure(function (Span $span) use (&$traceId, &$spanId) {
->measure(function (SpanInterface $span) use (&$traceId, &$spanId) {
$spanId = $span->getContext()->getSpanId();
$traceId = $span->getContext()->getTraceId();

Expand Down
2 changes: 1 addition & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function getRecordedSpans(): array

function withRootSpan(Closure $callback): mixed
{
$rootSpan = \Keepsuit\LaravelOpenTelemetry\Facades\Tracer::build('root')->startSpan();
$rootSpan = \Keepsuit\LaravelOpenTelemetry\Facades\Tracer::newSpan('root')->startSpan();
$rootScope = $rootSpan->activate();

$result = $callback();
Expand Down
5 changes: 3 additions & 2 deletions tests/TracerTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Keepsuit\LaravelOpenTelemetry\Facades\Tracer;
use OpenTelemetry\API\Trace\SpanInterface;
use OpenTelemetry\API\Trace\SpanKind;
use OpenTelemetry\API\Trace\StatusCode;
use OpenTelemetry\SDK\Common\Time\ClockFactory;
Expand Down Expand Up @@ -153,7 +154,7 @@

it('can measure a callback', function () {
/** @var Span $span */
$span = Tracer::measure('test span', function (Span $span) {
$span = Tracer::measure('test span', function (SpanInterface $span) {
TestTime::addSecond();

expect($span)
Expand All @@ -174,7 +175,7 @@
$callbackSpan = null;

try {
Tracer::measure('test span', function (Span $span) use (&$callbackSpan) {
Tracer::measure('test span', function (SpanInterface $span) use (&$callbackSpan) {
$callbackSpan = $span;

throw new Exception('test exception');
Expand Down

0 comments on commit 837197d

Please sign in to comment.