From c2a74fd611b4fc52592bc1276b6a131872145e7a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Feb 2026 09:18:14 +0000 Subject: [PATCH] Store timestamp as microtime float instead of truncated int Removes the (int) cast on the microtime(true) value so timestamps retain microsecond precision. Updates the corresponding test to assert a float. https://claude.ai/code/session_01CNzHGDAxDHo3s1sMhrLALx --- src/TracingResolver.php | 2 +- tests/TracingResolverTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/TracingResolver.php b/src/TracingResolver.php index a0cb01e..ab34059 100644 --- a/src/TracingResolver.php +++ b/src/TracingResolver.php @@ -99,7 +99,7 @@ public function resolve(Source $source): Result $duration = (microtime(true) - $start) * 1000; // Generic metadata — captured for every node automatically - $node->addMetadata('timestamp', (int) $start); + $node->addMetadata('timestamp', $start); $node->addMetadata('duration_ms', round($duration, 3)); $node->addMetadata('outcome', $result->isOk() ? 'ok' : 'err'); diff --git a/tests/TracingResolverTest.php b/tests/TracingResolverTest.php index 72bfa8b..ca8f689 100644 --- a/tests/TracingResolverTest.php +++ b/tests/TracingResolverTest.php @@ -219,16 +219,16 @@ public function test_duration_is_non_negative(): void $this->assertGreaterThanOrEqual(0, $duration); } - public function test_timestamp_is_a_unix_timestamp(): void + public function test_timestamp_is_a_microtime_float(): void { - $before = (int) microtime(true); + $before = microtime(true); $tracer = $this->createResolver(); $traced = $tracer->traced(new StaticSource(1)); - $after = (int) microtime(true); + $after = microtime(true); $timestamp = $traced->trace->getMetadata('timestamp'); - $this->assertIsInt($timestamp); + $this->assertIsFloat($timestamp); $this->assertGreaterThanOrEqual($before, $timestamp); $this->assertLessThanOrEqual($after, $timestamp); }