Skip to content

Commit 89d6766

Browse files
committed
chore: reformat
1 parent 67e19fd commit 89d6766

File tree

7 files changed

+25
-44
lines changed

7 files changed

+25
-44
lines changed

src/Concerns/InteractsWithCurrentSpan.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace PlunkettScott\LaravelOpenTelemetry\Concerns;
44

55
use Exception;
6-
use OpenTelemetry\SDK\Trace\Span;
76
use PlunkettScott\LaravelOpenTelemetry\CurrentSpan;
87

98
trait InteractsWithCurrentSpan

src/Otel.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,20 @@
33
namespace PlunkettScott\LaravelOpenTelemetry;
44

55
use Illuminate\Foundation\Application;
6-
use OpenTelemetry\API\Trace\NoopSpanBuilder;
76
use OpenTelemetry\API\Trace\NoopTracer;
8-
use OpenTelemetry\API\Trace\SpanInterface;
97
use OpenTelemetry\API\Trace\SpanKind;
108
use OpenTelemetry\API\Trace\StatusCode;
119
use OpenTelemetry\API\Trace\TracerInterface;
1210
use OpenTelemetry\Context\Context;
1311
use OpenTelemetry\SDK\Trace\TracerProviderInterface;
14-
use PlunkettScott\LaravelOpenTelemetry\Contracts\NamedSpanManagerContract;
1512
use Throwable;
1613

1714
class Otel
1815
{
1916
use Concerns\RegistersWatchers,
2017
Concerns\InteractsWithCurrentSpan;
2118

22-
static public TracerInterface $tracer;
19+
public static TracerInterface $tracer;
2320

2421
/**
2522
* Start OpenTelemetry for Laravel
@@ -80,17 +77,21 @@ public static function tracer(): TracerInterface
8077
* scope. The scope must be detached and the span must be ended manually. Passing the returned array to spanEnd will
8178
* end the span and detach the scope for you.
8279
*
83-
* @param string $name The name of the span
84-
* @param callable|null $callable A callable that will be executed within the span context. The activated Span will be passed as the first argument.
85-
* @param int $kind The kind of span to create. Defaults to SpanKind::KIND_INTERNAL
86-
* @param iterable $attributes Attributes to add to the span. Defaults to an empty array, but can be any iterable.
80+
* @param string $name The name of the span
81+
* @param callable|null $callable A callable that will be executed within the span context. The activated Span will be passed as the first argument.
82+
* @param int $kind The kind of span to create. Defaults to SpanKind::KIND_INTERNAL
83+
* @param iterable $attributes Attributes to add to the span. Defaults to an empty array, but can be any iterable.
8784
* @return mixed The result of the callable
85+
*
8886
* @throws Throwable If the callable throws an exception, it will be rethrown and the span will be ended with the exception recorded.
8987
*/
9088
public static function span(string $name, callable $callable = null, int $kind = SpanKind::KIND_INTERNAL, iterable $attributes = []): mixed
9189
{
9290
if (! config('otel.enabled')) {
93-
if (is_null($callable)) return null;
91+
if (is_null($callable)) {
92+
return null;
93+
}
94+
9495
return $callable(CurrentSpan::get());
9596
}
9697

src/OtelServiceProvider.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
namespace PlunkettScott\LaravelOpenTelemetry;
44

55
use Illuminate\Support\ServiceProvider;
6-
use OpenTelemetry\API\Trace\TracerInterface;
7-
use OpenTelemetry\API\Trace\TracerProviderInterface;
86
use PlunkettScott\LaravelOpenTelemetry\Console\Commands;
9-
use PlunkettScott\LaravelOpenTelemetry\Contracts\NamedSpanManagerContract;
10-
use PlunkettScott\LaravelOpenTelemetry\Support\NamedSpanManager;
117

128
class OtelServiceProvider extends ServiceProvider
139
{

src/Watchers/CacheWatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CacheWatcher extends Watcher
1515
public ?string $optionsClass = CacheWatcherOptions::class;
1616

1717
/**
18-
* @inheritDoc
18+
* {@inheritDoc}
1919
*/
2020
public function register(Application $app): void
2121
{

src/Watchers/CacheWatcherOptions.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
final readonly class CacheWatcherOptions extends WatcherOptions
66
{
77
/**
8-
* @param bool $record_cache_hit When true, cache hits will be recorded as span events.
9-
* @param bool $record_cache_miss When true, cache misses will be recorded as span events.
10-
* @param bool $record_cache_set When true, cache sets will be recorded as span events.
11-
* @param bool $record_cache_forget When true, cache forgets will be recorded as span events.
12-
* @param array $ignored An array of cache keys to ignore. Accepts wildcards, e.g. 'users.*'.
8+
* @param bool $record_cache_hit When true, cache hits will be recorded as span events.
9+
* @param bool $record_cache_miss When true, cache misses will be recorded as span events.
10+
* @param bool $record_cache_set When true, cache sets will be recorded as span events.
11+
* @param bool $record_cache_forget When true, cache forgets will be recorded as span events.
12+
* @param array $ignored An array of cache keys to ignore. Accepts wildcards, e.g. 'users.*'.
1313
*/
1414
public function __construct(
1515
public bool $record_cache_hit = true,

src/Watchers/ClientRequestWatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function recordRequest(RequestSending $request): void
4141
$processedUrl = $parsedUrl->get('scheme').'://'.$parsedUrl->get('host').$parsedUrl->get('path', '');
4242

4343
if ($parsedUrl->has('query')) {
44-
$processedUrl .= '?' . $parsedUrl->get('query');
44+
$processedUrl .= '?'.$parsedUrl->get('query');
4545
}
4646

4747
$span = $this->tracer->spanBuilder('http '.$request->request->method().' '.$request->request->url())

src/helpers.php

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
* Returns an OpenTelemetry tracer instance. If OpenTelemetry is not enabled,
1313
* a NoopTracer will be returned instead making this function safe to call
1414
* in all environments.
15-
*
16-
* @return TracerInterface
1715
*/
1816
function tracer(): TracerInterface
1917
{
@@ -27,10 +25,10 @@ function tracer(): TracerInterface
2725
* be ended when the callable returns or throws an exception. The callable may
2826
* modify the active span by accepting a SpanInterface as its first argument.
2927
*
30-
* @param string $name The name of the span
31-
* @param callable $callable A callable that will be executed within the span context. The activated Span will be passed as the first argument.
32-
* @param int $kind The kind of span to create. Defaults to SpanKind::KIND_INTERNAL
33-
* @param iterable $attributes Attributes to add to the span. Defaults to an empty array, but can be any iterable.
28+
* @param string $name The name of the span
29+
* @param callable $callable A callable that will be executed within the span context. The activated Span will be passed as the first argument.
30+
* @param int $kind The kind of span to create. Defaults to SpanKind::KIND_INTERNAL
31+
* @param iterable $attributes Attributes to add to the span. Defaults to an empty array, but can be any iterable.
3432
* @return mixed The result of the callable
3533
*
3634
* @throws Throwable If the callable throws an exception, it will be rethrown and the span will be ended with the exception recorded.
@@ -43,9 +41,8 @@ function span(string $name, callable $callable, int $kind = SpanKind::KIND_INTER
4341

4442
if (! function_exists('span_event')) {
4543
/**
46-
* @param string $name Event name
47-
* @param iterable $attributes Event attributes
48-
* @return SpanInterface
44+
* @param string $name Event name
45+
* @param iterable $attributes Event attributes
4946
*/
5047
function span_event(string $name, iterable $attributes = []): SpanInterface
5148
{
@@ -55,9 +52,8 @@ function span_event(string $name, iterable $attributes = []): SpanInterface
5552

5653
if (! function_exists('span_attribute')) {
5754
/**
58-
* @param string $name Attribute name
59-
* @param mixed $value Attribute value
60-
* @return SpanInterface
55+
* @param string $name Attribute name
56+
* @param mixed $value Attribute value
6157
*/
6258
function span_attribute(string $name, mixed $value): SpanInterface
6359
{
@@ -68,9 +64,6 @@ function span_attribute(string $name, mixed $value): SpanInterface
6864
if (! function_exists('span_error')) {
6965
/**
7066
* Set the Span status to Error with an optional description.
71-
*
72-
* @param string|null $description
73-
* @return SpanInterface
7467
*/
7568
function span_error(string $description = null): SpanInterface
7669
{
@@ -82,10 +75,6 @@ function span_error(string $description = null): SpanInterface
8275
/**
8376
* Set the Span status to Error if the condition is true. Otherwise, return
8477
* the current span.
85-
*
86-
* @param bool $condition
87-
* @param string|null $description
88-
* @return SpanInterface
8978
*/
9079
function span_error_if(bool $condition, string $description = null): SpanInterface
9180
{
@@ -97,10 +86,6 @@ function span_error_if(bool $condition, string $description = null): SpanInterfa
9786
/**
9887
* Set the Span status to Error if the condition is false. Otherwise, return
9988
* the current span.
100-
*
101-
* @param bool $condition
102-
* @param string|null $description
103-
* @return SpanInterface
10489
*/
10590
function span_error_unless(bool $condition, string $description = null): SpanInterface
10691
{

0 commit comments

Comments
 (0)