Skip to content

Commit 9c3ecc9

Browse files
authored
Fixes for PHPUnit errors in the Curl instrumentation library (#371)
* openaiphp phpunit failure fix * curl intermittent phpunit failure fix * php-cs-fixer * revert 95fea86
1 parent 105e773 commit 9c3ecc9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/Instrumentation/Curl/src/CurlInstrumentation.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use OpenTelemetry\SemConv\TraceAttributes;
1919
use OpenTelemetry\SemConv\Version;
2020
use WeakMap;
21-
use WeakReference;
2221

2322
class CurlInstrumentation
2423
{
@@ -35,7 +34,7 @@ public static function register(): void
3534
* 'handles'=>
3635
* WeakMap[CurlHandle] => {
3736
* 'finished' => bool,
38-
* 'span' => WeakReference<SpanInterface>
37+
* 'span' => SpanInterface
3938
* }
4039
* )
4140
*/
@@ -327,7 +326,7 @@ public static function register(): void
327326
}
328327
$curlSetOptInstrumentationSuppressed = false;
329328

330-
$metadata['span'] = WeakReference::create($span);
329+
$metadata['span'] = $span;
331330
}
332331
$mHandle['started'] = true;
333332
}
@@ -339,7 +338,7 @@ public static function register(): void
339338
foreach ($handles as $cHandle => &$metadata) {
340339
if ($metadata['finished'] == false) {
341340
$metadata['finished'] = true;
342-
self::finishMultiSpan(CURLE_OK, $cHandle, $curlHandleToAttributes, $metadata['span']?->get()); // there is no way to get information if it was OK or not without calling curl_multi_info_read
341+
self::finishMultiSpan(CURLE_OK, $cHandle, $curlHandleToAttributes, $metadata['span']); // there is no way to get information if it was OK or not without calling curl_multi_info_read
343342
}
344343
}
345344

@@ -379,7 +378,7 @@ public static function register(): void
379378

380379
/** @psalm-suppress PossiblyNullArrayAccess */
381380
$currentHandle['finished'] = true;
382-
self::finishMultiSpan($retVal['result'], $retVal['handle'], $curlHandleToAttributes, $currentHandle['span']?->get());
381+
self::finishMultiSpan($retVal['result'], $retVal['handle'], $curlHandleToAttributes, $currentHandle['span']);
383382
}
384383
}
385384
}

0 commit comments

Comments
 (0)