From d31ae5fa061b498fe889c99a9dcde112bcd10051 Mon Sep 17 00:00:00 2001 From: Shawn Maddock Date: Wed, 21 May 2025 07:29:52 -0500 Subject: [PATCH] openaiphp phpunit failure fix --- src/Instrumentation/OpenAIPHP/src/OpenAIPHPInstrumentation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Instrumentation/OpenAIPHP/src/OpenAIPHPInstrumentation.php b/src/Instrumentation/OpenAIPHP/src/OpenAIPHPInstrumentation.php index 8be64d0db..8511a583f 100644 --- a/src/Instrumentation/OpenAIPHP/src/OpenAIPHPInstrumentation.php +++ b/src/Instrumentation/OpenAIPHP/src/OpenAIPHPInstrumentation.php @@ -193,7 +193,7 @@ private static function hookApi(CachedInstrumentation $instrumentation, $class, private static function recordUsage(SpanInterface $span, object $response, ContextInterface $context) { - if (!property_exists($response, 'usage') || !method_exists($response->usage, 'toArray')) { + if (!property_exists($response, 'usage') || !isset($response->usage) || !method_exists($response->usage, 'toArray')) { return; }